Can someone please tell me what I’m missing here to make this spin 360 degrees. I was able to do it without using PVectors but it doesn’t seem to work when I alter with code with PVectors. I’m still just getting the hang of them.
In the end, I want to produce a ‘spin the bottle’ type of loop but for now, this much would do - have it spin.
Thanks!
PVector radius;
PVector angle;
PVector aVel;
PVector aAccel;
void setup () {
size (600, 600);
}
void draw () {
background (255);
PVector location = new PVector (0.0, 0.0);
PVector aVel = new PVector (0.0, 0.0);
PVector aAccel = new PVector (0.0, 0.0);
PVector radius = new PVector (150.0, 0.0);
PVector angle = new PVector (0.0, 0.0);
translate (width/2, height/2);
location.x= radius.x * cos(angle.x);
location.y = radius.x * sin(angle.x);
fill (0);
stroke (0);
line (0, 0, location.x, location.y);
ellipse (location.x, location.y, 50, 50);
angle.add(aVel);
aVel.add(aAccel);
}
My initial code is a copy from Daniel Schiffman’s video youtube video. It works.
float r = 150;
float a = 0.0;
float aVel = 0.0;
float aAccel = 0.001;
void setup () {
size (600,600);
}
void draw () {
background (255);
translate (width/2, height/2);
float x = r * cos(a);
float y = r * sin(a);
fill (0);
stroke (0);
line (0,0, x,y);
ellipse (x,y,50,50);
a += aVel;
aVel += aAccel;
aVel = constrain(aVel, 0,0.35);
}