We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › I get lost in multiple rotations
Page Index Toggle Pages: 1
I get lost in multiple rotations (Read 564 times)
I get lost in multiple rotations
Jun 23rd, 2008, 1:34pm
 
Hi,

I try to program a rolling sphere, with a character in it. The sphere's going in every direction of the xz-plane, however, I get lost in the rotateZ and rotateX calls, because they affect each other(, and probably I even have to rotate around the Y axis...). I've also used sin and cos to include rotateX's influence on rotateZ, I can't get a satisfying result.
You can find the sketch and source code at:

http://benmeijering.nl/p5/applet/

Any help is appreciated.

~ Ben
Re: I get lost in multiple rotations
Reply #1 - Jun 24th, 2008, 11:18am
 
hey, shouldn't you use quaternions? since you need to rotate your sphere around specific axes, I think this is the solution. it's often useful when you're stuck with (x, y, z) rotations.

Re: I get lost in multiple rotations
Reply #2 - Jun 25th, 2008, 10:11am
 
antiplastic, thanks!
these quaterniouns seem very promising; very mathematical, but luckily some p5 people already dug into the matter, thanks!
Re: I get lost in multiple rotations
Reply #3 - Jun 25th, 2008, 11:53am
 
yes, I used them already to display 3D animated characters. you could easily reuse some methods from the sketch :
http://n.clavaud.free.fr/processing/SimplePickingPlusAnimation/

especially these classes : Quat4f and AxisAngle4f

if I remember well, I used quaternions for some rotation calculations, then converted the result into (axis,angle) format and just called rotate(angle, x, y, z) to get the appropriate rotation in Processing.

Re: I get lost in multiple rotations
Reply #4 - Jun 25th, 2008, 9:42pm
 
Antiplastik, thanks!
I'll definitely take a look at it and see if I'm able to understand the idea behind the code, to be able to reuse it.
As soon as I have managed so, I'll make a post.
* Great sketch btw. I once thought about making a bvh-file interpreter, to animate characters, using mocap data. You've done it algorithmically: nice!

~ Ben
Page Index Toggle Pages: 1