How To Rotate A 3d Object (given A Vector)?

Hi! i would like to rotate an object according to a given vector, using MEL. Any recommendations on how this task might be achieved?

Why do you need to rotate it and what would that vector represent? Rotation in 3d space is not fully defined with just one vector. Consider using aim constraint.

QUOTE(failure @ 12/11/05, 07:30 PM)
Why do you need to rotate it and what would that vector represent? Rotation in 3d space is not fully defined with just one vector. Consider using aim constraint.
[snapback]222076[/snapback]

Sorry that my question is unclear. i would like to change my question to "i would like to find out the angle between two vectors u and v using the mathematical formula inverse cosine[(u.v)/(|u||v|)]. Is there any MEL command, such as inverse cosine, that can help me to calculate it?"

Why don't you look into reference?

QUOTE(failure @ 12/11/05, 08:38 PM)
Why don't you look into reference?
[snapback]222078[/snapback]

i have come across cos command in Maya Help. But no inverse cos command is found. So im wondering if there are any other commands that might be helpful. Anyway, thank you

read the description for cos

btw there's angle command which returns angle between two vectors so you don't need to calculate it via dot product.

CODE
rad_to_deg( angle( <>, <> ) );

QUOTE(failure @ 12/11/05, 09:17 PM)
read the description for cos

btw there's angle command which returns angle between two vectors so you don't need to calculate it via dot product.

CODE
rad_to_deg( angle( <>, <> ) );

[snapback]222080[/snapback]

Thanks a lot. i have also just come across the angle command too. This is probably what i need.

If you want to map one vector onto another less painful way is to find angle ( which you now know how ) and rotation axis ( using cross product ). Then construct a quaternion. You can easily make a transformation matrix out of quaternion.

oe you can use axis angle... It can sometimes be easier to visualize than quarteronion. TOugh quarteronion handles the siungularity WAY better.

Nonetheless i do tend to use axisangle aon occasion.