quick MVector question

29 views
Skip to first unread message

Rudi Hammad

unread,
Jul 18, 2016, 5:08:50 AM7/18/16
to Python Programming for Autodesk Maya
hello,
I want to get the vector between two objects, so what I do is create pointA and pointB as instances MPoints, and then

vectorA = OpenMaya.MVector(pointA); vectorB = OpenMaya.MVector(pointB)
vectorBetween = vectorB - vectorA

Out of curiosity,I was wondering if you can directly get the vector between two objects without having to do the substraction. Something like vectorBetween = OpenMaya.MVector(pointA, pointB)
Does MVector return only vectors having the origin in (0,0,0)

thx


Christopher Crouzet

unread,
Jul 18, 2016, 5:45:22 AM7/18/16
to python_in...@googlegroups.com
You don't need to convert both MPoint instances to MVector before subtracting them. As per the documentation page for MPoint (check the `operator-(MPoint)` method), if you subtract two MPoint objects you get a MVector as a result:

vectorBetween = pointB - pointA


Not sure why you'd want to avoid doing a subtraction?


--
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/aff78d2f-5805-4703-84f6-e89d1ac184d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Rudi Hammad

unread,
Jul 18, 2016, 6:08:47 AM7/18/16
to Python Programming for Autodesk Maya

El lunes, 18 de julio de 2016, 11:45:22 (UTC+2), Christopher Crouzet escribió:
You don't need to convert both MPoint instances to MVector before subtracting them. As per the documentation page for MPoint (check the `operator-(MPoint)` method), if you subtract two MPoint objects you get a MVector as a result:

vectorBetween = pointB - pointA

That´s true. douuh!!!


Not sure why you'd want to avoid doing a subtraction?
 
No reason.I thought that maybe I was doing an unnecessary step or there was a more proper way.
Thanks
Reply all
Reply to author
Forward
0 new messages