View Full Version : Rotating "down"
stuh505 10232005, 06: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?


prettyPixel
10242005, 02: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.
theAxis=normalize (p2p1)
q=quat 45 theAxis
theRotCenter=p1
thisCoord=((thisCoordtheRotCenter)*q)+theRotCenter
stuh505
10242005, 03: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!!
prettyPixel
10242005, 03: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 ?
stuh505
10242005, 04: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 (endstart)
shape.pivot = start
rotateDir = cross dir [0,0,1]
q = quat 10 rotateDir
rotate shape q
CGTalk Moderation
10242005, 04: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 ©20002015, Jelsoft Enterprises Ltd.