class SpinPoint{ float xtheta; float xtheta_vel; float ytheta; float ytheta_vel; float ztheta; float ztheta_vel; float amplitude; float x,y,z; float xamp; float yamp; float zamp; //**********CONSTRUCTOR**********// SpinPoint(float xvel, float yvel, float zvel, float xt, float yt, float zt) { //set arguments as variables xtheta = xt; ytheta = yt; ztheta = zt; xtheta_vel = xvel; ytheta_vel = yvel; ztheta_vel = zvel; } void spin(float xamp_, float yamp_, float zamp_){ //increment thetas xtheta+=random(.01); ytheta+=random(.01); ztheta+=random(.01); //set arguments as variables | Amplitude is the distance from the center of motion to either extreme. xamp = xamp_; yamp = yamp_; zamp = zamp_; /* Amplitude: the distance from the center of motion to either extreme. Period: the amount of time it takes for one complete cycle of motion. Frequency: the number of of cycles per time unit (1 / period). The position x as a function of time t can be expressed as: x (t) = Amplitude * cosine ( 2 * PI * t / Period ) */ //calculate oscillation along x axis amplitude = xamp; x = amplitude * sin(xtheta); xtheta += xtheta_vel; //calculate oscillation along y axis amplitude = yamp; y = amplitude * cos(ytheta); ytheta += ytheta_vel; //calculate oscillation along z axis amplitude = zamp; z = amplitude * sin(ztheta); ztheta += ztheta_vel; } float getX(){ return x; } float getY(){ return y; } float getZ(){ return z; } }