Re: [Maya-Python] quick way of finding perpendicular vector?

476 views
Skip to first unread message

Marcus Ottosson

unread,
Oct 29, 2014, 9:40:44 AM10/29/14
to python_in...@googlegroups.com
As mentioned in my previous reply, crossproduct() should sort things out.

Best,
Marcus

On 29 October 2014 12:30, sam williams <samwill...@gmail.com> wrote:
Hello;)

im trying to find the perpendicular vector to a vector. I know i need to use the cross product, but it can be tedious to write is all out manually. But does anyone know of an in built way of finding it in python. other than using numpy. 

thanks alot, 
Sam

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/59288e12-505b-4444-9d2f-0feb2fdfbe75%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Marcus Ottosson
konstr...@gmail.com

Risto Jankkila

unread,
Oct 29, 2014, 9:42:19 AM10/29/14
to python_in...@googlegroups.com
Hi,

You need two vectors for cross product. If you want you can find a random tangent for a single vector, but that's slightly more complicated.

For cross-product you can use the mel-command 'cross' or the MVector-class from Python API that has overloaded operator for cross product (the caret-symbol).

Example code for api:
import maya.api.OpenMaya as api
p1 = [0, 1, 0]
p2 = [1, 0, 0]
vec_p1 = api.MVector(p1)
vec_p2 = api.MVector(p2)
cross = vec_p1^vec_p2

Hope that helps.

Cheers,
Risto





Reply all
Reply to author
Forward
0 new messages