
PDE Download: Test03sLorentz.pde
JAVA Download: Test03sLorentz.java
Click on anar+ terms to get the documentation.
import processing.opengl.*;
import anar.*;
/*
* Example for Anar library by Guillaume LaBelle + Julien Nembrini
* http://anar.ch
*/
Obj myObj;
Param a, b, c, h, w;
void setup(){
size(800,400,OPENGL);
Anar.init(this);
Anar.drawAxis();
a = new Param(10,0,40,"a");
b = new Param(28,0,100,"b");
c = new Param(8/3f,0,10,"c");
h = new Param(0.02f,0,0.1f,"h");
w = new Param(0.5f,0,1,"w");
Anar.sliders(a);
Anar.sliders(b);
Anar.sliders(c);
Anar.sliders(h);
Anar.sliders(w);
initForm();
}
void initForm(){
myObj = new Obj();
Pts curveCtrl = new Pts();
// Create a first point
Pt base = Anar.Pt(0.1f,0,0);
curveCtrl.add(base);
// This equation is not not linear, we have to calculate every points
for (int i = 0; i<1000; i++){
float x1 = base.x()+h.get()*a.get()* (base.y()-base.x());
float y1 = base.y()+h.get()* (base.x()* (b.get()-base.z())-base.y());
float z1 = base.z()+h.get()* (base.x()*base.y()-c.get()*base.z());
base = Anar.Pt(x1,y1,z1);
curveCtrl.add(base);
}
// Create a curve based on all the points
CSpline curve = new CSpline(curveCtrl);
myObj.add(curve);
Anar.camTarget(myObj);
// Snap a point on the Curve
Pt ptOnCurve = new PtCurve(curve,w);
myObj.add(ptOnCurve);
}
void draw(){
background(155);
myObj.draw();
}
void keyPressed(){
if(key==' ')
initForm();
}

|