Notifications
Clear all

[Closed] Rotating "down"

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?

4 Replies

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 (p2-p1)
q=quat 45 theAxis
theRotCenter=p1
thisCoord=((thisCoord-theRotCenter)*q)+theRotCenter

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!!

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 ?

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