View Full Version : Rotating "down"
10-23-2005, 05:30 PM
I'm trying to write a little function to simply rotate a spline towards -Z within the plane that contains the first and last CV's.
My plan was to calculate the vector between these CV's, make a matrix from this, set the pivot point to the first CV, and then in the coordinate system of that vector apply a euler rotation to the spline of [rotationValue,0,0]...but this didn't work.
How should I go about this?
10-24-2005, 01:55 AM
You want to say the plan defined by the normal of the vector that passes by the first and last point ?
The only thing to make is to define a quad based on your axis.
q=quat 45 theAxis
10-24-2005, 02:00 AM
No, let me clarify. I am not talking about the plane that is defined by the normal...I am talking about the plane that contains the two points which is vertical. So, for example, if the two points were [0,0,0] and [1,1,0] then the plane would be the XY plane, because it contains both and is vertical. I would want to rotate the shape in this plane. I could compute the final location I think by converting to spherical coordinates, but that doesn't help me much...because I need the rotation value to apply the movement with a "rotate" command.
edit: Actually, your method is all I needed...because I can just compute the correct normal plane by doing the cross product with [0,0,1] !!! Thanks pixel!!
10-24-2005, 02:21 AM
I will be curious to know what you do if your points are those.
[0,0,0] and [1,1,1]
How do you find the famous plane that contains both and is vertical ?
10-24-2005, 03:50 AM
Almost exactly what you said, except I don't want to rotate in the plane that is defined by the object's dir, but rather the plane that contains the object's dir and is vertical...the normal to that plane is simply "dir cross [0,0,1]"
start = (getKnotPoint shape 1 1)
end = (getKnotPoint shape 1 (numKnots shape))
dir = normalize (end-start)
shape.pivot = start
rotateDir = cross dir [0,0,1]
q = quat -10 rotateDir
rotate shape q
10-24-2005, 03:50 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.