FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Simulation, Artificial Life
(Moderator: REAS)
   Question - Object Rotation
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Question - Object Rotation  (Read 1066 times)
Mike Davis

WWW
Question - Object Rotation
« on: May 6th, 2004, 10:15pm »

I'm trying to give an object orientation, and allow it to rotate by pitch, yaw, and roll relative to it's own previous orientation.
 
My thinking is that I need to maintain three vectors for the object representing the axes for pitch, yaw, and roll.  Rotation would then mean altering two vectors are a time: rotating pitch would be rotating the yaw axis and roll axis vectors around the pitch axis, which would remain the same.
 
I'm wondering:
1) Does anyone know of a good eq or matrix for rotating a vector around another vector (as opposed to a coordinate axis)?
2) Am I overlooking an easier or better of doing this?  One obvious drawback to this method is that the vectors will accumulate error on each rotation, though it would be easy to regularly check that the vectors are orthogonal enough and reset two of them if not.
 
arielm

WWW
Re: Question - Object Rotation
« Reply #1 on: May 6th, 2004, 10:37pm »

maybe quaternions are what you're looking for?
 

Ariel Malka | www.chronotext.org
Mike Davis

WWW
Re: Question - Object Rotation
« Reply #2 on: May 6th, 2004, 11:01pm »

That's a perfect starting point for me.  Thanks!
 
narain


Re: Question - Object Rotation
« Reply #3 on: May 7th, 2004, 6:59am »

There's an easier way to do yaw, pitch and roll, if all you want to affect is the axis vectors.
 
I'm going to call the three axis vectors front, left and top. If you want to turn up, ie rotate around the left vector, (vector-based pseudocode follows)
[front, top] = [front*cos + top*sin, -front*sin + top*cos]
(Simultaneous assignment: you'll need a temp variable. Of course, cos and sin will take the angle to turn as argument.)
 
Similarly for turning left/right and rolling.
 
Pages: 1 

« Previous topic | Next topic »