PDA

View Full Version : aligning objects to a vector


saiwa
01-26-2007, 07:56 AM
I need to align a cylinder to a vector. In other words I know the coordinates of the vector starting (x1,y1,z1) and ending point (x2,y2,z2), and I would like to create a cylinder that is appropriately rotated in order to have a base centered on the first point and the other base centered on the second point. (The cyclinder is not a mesh, but a primitive object)
I'm relatively new to maxscript, and it seems I cannot solve this problem alone... any advice will be greatly appreciated.

Thanx, Saiwa

j-man
01-26-2007, 11:07 AM
there is an excellent 'how too' in the MXS help regarding almost exactly this!

"how do i find the angle between 3 vertices"

ok, so you need to calculate the vector from one point to the other, and then point your object along that vector

$.dir=(normalize (p2-p1))

have a good read the how toos and practical examples in the help.

J.

saiwa
01-26-2007, 12:01 PM
thank you for your fast reply :)
I will give it a try as soon as possible

saiwa

CGTalk Moderation
01-26-2007, 12:01 PM
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.