9.1 COMPUTATIONAL SCRIPTS

GRAVITY SCRIPT /////////////////////////////////////////////////////////////////////////////////////////////// import peasy.*; import processing.opengl.*; import toxi.physics.*; import toxi.geom.*; import toxi.physics.constraints.*; PeasyCam cam; VerletPhysics physics; Str strspr; PrintWriter output; VerletParticle p1,p2; ArrayList lockpt=new ArrayList(); ArrayList originalPts=new ArrayList(); ArrayList endPts=new ArrayList(); ArrayList allStr=new ArrayList(); //ArrayList connectionPts=new ArrayList();r ArrayList allCon=new ArrayList(); ArrayList allCon2=new ArrayList(); StrFromPts connectionSpr;

IX

CHAPTER 9_APPENDIX

float restLength=5.5; int stepNum=20; float stepDist=5; float strength=1; int lineNum=67; Integer lockptNum; int ConNum=10; int edgeNum=10; float rlSpeed=0.0;

226

//tempt setting/////// VerletParticle selectPt1; VerletParticle selectPt2;

//****************************************************************** void setup() { fixedSetting(); output=createWriter(“sdl_front_05.txt”); //longitude line------------------------------------//original two end points p1 = new VerletParticle(0,0,50); p2 = new VerletParticle(0,100,50); //constructor original points arraylist for(int i=0;i<lineNum;i++) { VerletParticle tp1=new VerletParticle(p1. x+1.5*i,p1.y,p1.z); VerletParticle tp2=new VerletParticle(p2. x+1.5*i,p2.y,p2.z); originalPts.add(tp1); endPts.add(tp2);

} // Str(VerletParticle _OriPts,float _restLength,float _ stepNum,float _stepDist,float _strength,ArrayList _lockNum) //the point sequence which need to be locked for(int i=0;i<stepNum;i+=stepNum) { lockptNum=i; lockpt.add(lockptNum); } for(int i=0;i<lineNum;i++) { VerletParticle op=(VerletParticle)originalPts.get(i); VerletParticle ep=(VerletParticle)endPts.get(i);

strspr=new Str(op,ep,restLength+i*rlSpeed,stepNum,step Dist,strength,lockpt);

}