ChrisBatho/Lorenz Plot
Jump to navigation
Jump to search
Describe Chris-Batho here.
This is the control panel [{{#file: "lorenz.ijs"}} Download script: lorenz.ijs ]
NB. The Lorenz Attractor for j601 version 1.02 NB. by [[User:Chris Batho|Chris Batho]], and Oleg Kobchenko NB. http://www.jsoftware.com/jwiki/Scripts NB. June 2007 Note Stereo View by Devon McCormick NB. s r b nominal 10 , 28 , 8%3
This is the rotating view
Main function to calc and display lorenz. [{{#file: "lorenz.ijs"}} Download script: lorenz.ijs ]
NB.=================================================== NB. main function to calc and display lorenz flag=:0 require 'viewmat graph numeric trig plot' lorenz=: 3 : 0 [A=: 0 [B=: 0 [C=: 0 'X Y Z'=:0.01, 0.01, 0.01 NB. define X Y Z 's r b num_inc' =. y for. i.num_inc do. dt=. 0.005 X=: X + (s*(Y - X))*dt Y=: Y + ((X * r) -(X*Z) - Y)*dt Z=: Z + ((X*Y) - b*Z)*dt [A=: A,X [B=: B,Y [C=: C,Z pd 'pensize 1' pd 'axes 1 1 1' pd 'type line' pd 'labels 1' pd 'viewsize 2' pd 'title Lorenz' pd 'color darkblue' 'viewpoint 7.2 1.2 6.4 ;framebackcolor white' plot A; B; C end. )
Funcions associated with main. [{{#file: "lorenz.ijs"}} Download script: lorenz.ijs ]
NB.=================================================== NB. associated funcions rotz_z_=: ] +/ .* ((cos,sin),:-@sin,cos)@[ , 0 0 1"_ stereo=: 3 : 0 pd 'sub 1 2;new;boxed 0' pd 'color red' pd 'viewpoint ',":vp=. _4.6 3.9 1.5 pd 'viewsize 1' pd A;B;C pd 'new;boxed 0' pd 'color red' NB. pd 'viewpoint ',":1r25p1 rotz_z_ vp pd 'viewpoint ',":1r50p1 rotz_z_ vp pd 'viewsize 1' pd A;B;C pd 'show' ) rotator=: 3 : 0 pd 'color green' pd 'viewpoint ',":vp=. _4.6 3.5 1.4 pd 'viewsize 1' angle=: 1r24p1 while. angle < 1p1%3 do. pd A;B;C pd 'viewpoint ',":angle rotz_z_ vp pd 'show' delay 1 angle=: angle +(1p1%400) end. 'Rotation completed 'printf here=: '' ) sub=:(<:@] { [)`(([ (<:@] { [) >@{.@]) (<:@] {"1 [) >@{:@])@.(<:@#@$@[ *. #@]>1:) delay=: 3 : 0 c=: y c=: 3000 * c NB. 400 5 sec while. c > 0 do. c=: c - 1 c end. )
This is the Stereo View.
GUI input. [{{#file: "lorenz.ijs"}} Download script: lorenz.ijs ]
NB.=================================================== require 'strings printf' LORENZ=: 0 : 0 pc Lorenz;pn "Lorenz Equation Explorer"; menupop "File"; menu new "&New" "" "" ""; menu open "&Open" "" "" ""; menusep; menu exit "&Exit" "" "" ""; menupopz; xywh 165 15 30 11;cc editS edit; xywh 166 42 30 11;cc editR edit; xywh 166 67 30 11;cc editB edit; xywh 161 93 38 11;cc editNumiter edit; xywh 166 4 32 10;cc static1 static;cn "S nom 10"; xywh 166 31 31 10;cc static2 static;cn "R nom 28"; xywh 167 56 35 10;cc static3 static;cn "B nom 8/3"; xywh 162 82 40 10;cc static4 static;cn "Num. Steps"; xywh 103 95 34 11;cc bnPlot button;cn "Plot"; xywh 9 95 48 11;cc bnRotate button;cn "Rotate 30 deg"; xywh 11 3 34 11;cc bnEndview button;cn "End View"; xywh 11 18 34 11;cc bnSideview button;cn "Side View"; xywh 12 33 34 11;cc bnTopview button;cn "Top View"; xywh 3 54 43 11;cc bnOriginalview button;cn "Original View"; xywh 12 78 42 11;cc bnStereoview button;cn "Stereo View"; xywh 59 1 99 80;cc stDesc static;cn "stDesc"; pas 6 6;pcenter; rem form end; ) Lorenz_run=: 3 : 0 wd LORENZ NB. initialize form here wd 'set editS 10' wd 'set editR 28' wd 'set editB 2.6667' wd 'set editNumiter 2000' wd 'set stDesc *',Desc rplc LF;'' wd 'pshow;' ) Lorenz_close=: 3 : 0 wd'pclose' ) fire=: 3 : 0 s=: 1>.{.0".editS r=: 1>.{.0".editR b=: 1>.{.0".editB num_inc =. 1>.{.0".editNumiter lorenz s, r, b, num_inc ) Lorenz_bnPlot_button=: 3 : 0 fire'' flag=:1 'Plot completed 'printf nhere=: '' ) Lorenz_bnRotate_button=: 3 : 0 if. flag = 0 do. wdinfo 'Press the Plot button first' return. end. pd 'pensize 1' pd 'axes 1 1 1' pd 'type line' pd 'labels 1' pd 'viewsize 2' pd 'title Lorenz' pd 'color darkblue' 'viewpoint _4.6 3.5 1.4 ;framebackcolor white' plot A; B; C rotator '' ) Lorenz_bnEndview_button=: 3 : 0 if. flag = 0 do. wdinfo 'Press the Plot button first' return. end. pd 'pensize 1' pd 'axes 1 1 1' pd 'type line' pd 'labels 1' pd 'viewsize 2' pd 'title Lorenz' pd 'color darkblue' 'viewpoint 1 4 1;framebackcolor white' plot A; B; C ) Lorenz_bnSideview_button=: 3 : 0 if. flag = 0 do. wdinfo 'Press the Plot button first' return. end. pd 'pensize 1' pd 'axes 1 1 1' pd 'type line' pd 'labels 1' pd 'viewsize 2' pd 'title Lorenz' pd 'color darkblue' 'viewpoint 4 4 1;framebackcolor white' plot A; B; C ) Lorenz_bnTopview_button=: 3 : 0 if. flag = 0 do. wdinfo 'Press the Plot button first' return. end. pd 'pensize 1' pd 'axes 1 1 1' pd 'type line' pd 'labels 1' pd 'viewsize 2' pd 'title Lorenz' pd 'color darkblue' 'viewpoint 1 1 5 ;framebackcolor white' plot A; B; C ) Lorenz_bnOriginalview_button=: 3 : 0 if. flag = 0 do. wdinfo 'Press the Plot button first' return. end. pd 'pensize 1' pd 'axes 1 1 1' pd 'type line' pd 'labels 1' pd 'viewsize 2' pd 'title Lorenz' pd 'color darkblue' 'viewpoint 7.2 1.2 6.4 ;framebackcolor white' plot A; B; C ) Lorenz_bnStereoview_button=: 3 : 0 if. flag = 0 do. wdinfo 'Press the Plot button first' return. end. pd 'reset' stereo'' ) Desc=: 0 : 0 A Lorenz equation explorer which demonstrates dynamically the unique properties of this strange attractor. Different fixed viewpoints, 30 deg rotation, and a Stereo view are supported. The three variables s r and b are all adjustable for viewing variations in form. ) Lorenz_run'' NB.lorenz 13 28 2.67 160