Modify a text file: $/orbit/orbit1.java
$/orbit/orbit1.java
//////// On planet in orbit. // bam (CST112) float theta=0; // Angle from sun to planet. float sunX= width/2; float sunY= height/2; float sunR= 80; float pR= 10; // Radius of planet. float r= 100; // radius of planet's orbit. float x= sunX, y=sunY-r; // position of planet in orbit. float v= 10; // velocity. void setup() { size(800,800); theta=0; // Angle from sun to planet. sunX= width/2; sunY= height/2; sunR= 40; pR= 5; // Radius of planet. r= 150; // radius of planet's orbit. x= sunX; y= sunY-r; // position of planet in orbit. v= 2; // velocity. } void draw() { background ( 255 ); // background( 0 ); sun(); move(); show(); } void sun() { //// Draw the sun; fill( 255,255,0); ellipseMode(RADIUS); ellipse( sunX, sunY, sunR, sunR ); } void move() { //// Move in circular orbit x += v * cos(theta); y += v * sin(theta); theta += .01; } void show() { //// Show the planet at new position (x,y) fill( 0, 255, 255 ); ellipseMode( RADIUS ); ellipse( x, y, pR, pR ); }