Quote:Hi, how do you store the angles from peasyCam?
I tried getRotations() but the results are not that good.
mmmh i have to test (modify for the case) the following lines of code: they served to orient a tentacle section (from another sketch of mine) toward the next section.
Knowing where the peasyCam IS in space, and knowing where the object (the look at point) is, I should be able to get the 3 angles.
Will post back.
// Let particle b coords be the desired base center, and particle a coords be the desired top center.
Particle a;
Particle b;
//If that's where the center of the base stays, then the center of the top needs to end up at:
PVector c = new PVector(a.position().x()-b.position().x(),a.position().y()-b.position().y(),a.po
sition().z()-b.position().z());
float h = dist(0,0,0,c.x,c.y,c.z);
//then define the radius
float r = sqrt(pow(c.x,2)+pow(c.y,2)+pow(c.z,2));
float theta = atan2(c.y,c.x);
float phi = acos(c.z/r); //thank you Dave!
pushMatrix();
//now translate to b position
translate(b.position().x(),b.position().y(),b.position().z());
//and rotate the new tentacle segment
rotateZ(theta);
rotateY(phi);
rotateX(-HALF_PI);
//Segment to rotate
popMatrix();