class MOON{ //Initalize variables float r, Theta, Omega, v; /* where: r is the radius of the orbit Theta is the angular displacement Omega is the angular velocity v is velocity of the orbit */ //Attributes MOON(boolean rightSpin){ //works out the coordinates in polar form r = dist(width/2,height/2,mouseX,mouseY); Theta = atan((mouseY-height/2)/(mouseX-width/2)); //find Omega, the angular velocity v = sqrt((G*M)/r); Omega = v/sqrt(pow(r,2)); //define the direction of the orbit if (rightSpin==false){ Omega*=-1; } } //Methods void display(){ stroke(0); fill(0,255,0); ellipse(r*cos(Theta),r*sin(Theta),20,20); Theta+=Omega/frameRate; } }