PDA

View Full Version : Rotating an object parallel to a spline segment.


tommylommykins
06-13-2008, 08:34 PM
Hi all.

Part of a script I'm currently writing requires me to rotate a cylinder so that a particular spline segment would run through the centre of both of the cylinder's caps. Positioning the cylinder is not a problem, since I can set the .pos property of the cylinder to the position of one of the vertices defining the segment, but the required rotation to make it face the second vertex is beyond my very limited knowlege of vector arithmetic.

Any help with the required vector operations to get the cylinder object facing the right want would be a great help :)

...

I had tried a cheeky workaround that didn't involve explicit vector arithmetic by creating a temporary object at the position of the second vertex, assigning a LookAt controller to the cylinder targetted at that temporary object and getting the cylinder's rotation in that state via the .rotation property, however I strangely got NaN errors in the output, halting that plan.

ZeBoxx2
06-13-2008, 11:22 PM
you could use <node>.dir to set the direction the object should 'look at' as well; goes along positive Z.

magicm
06-14-2008, 10:40 AM
Lookup both interpCurve3D and tangentCurve3D in the manual. The first one returns a position based on a path parameter, the second a direction vector.

Cheers,
Martijn

CGTalk Moderation
06-14-2008, 10:40 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.