multipling om.MPoint() by negative 1

22 views
Skip to first unread message

s...@weacceptyou.com

unread,
Dec 21, 2016, 7:16:48 PM12/21/16
to Python Programming for Autodesk Maya
Hello,

i am trying to find how much i need to add to a coordinate in order to get to another coordinate using this equation

coords1=(2,3,5)
coords2=(4,5,6)

difference = -1*(coords1-coords2)

I am trying to do this with the python api though, which is always mental. I've done the bit in the brackets like this

(om.MFloatPoint(2,3,5)-om.MFloatVector(4,5,6))

but i don't know how to multiply the result by negative 1. Can anyone show me the api way?


thanks,
Sam

Justin Israel

unread,
Dec 21, 2016, 7:54:56 PM12/21/16
to python_in...@googlegroups.com
First, I am not sure why you don't just swap them around and do coords2-coords1, and be done with it? Why the need to scale by -1?

om.MFloatPoint(4,5,6) - om.MFloatPoint(2,3,5)

But that aside, if you really need to do it the way you have listed, the problem is that you are multiplying the wrong way around:

difference = (coords1-coords2) * -1

When you do it starting with -1 you end up accessing the multiplication operators on the int instead of the MFloatPoint. It is the MFloatPoint that knows how to be multiplied by an int value.

Justin


 


thanks,
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/c5976703-c764-452b-9e06-31c0a12f7631%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

alessia...@gmail.com

unread,
Dec 22, 2016, 1:25:50 PM12/22/16
to Python Programming for Autodesk Maya
ye i realise this, it was just to really check it was working properly because i need to change the signs later on.

thanks for the help
Sam
Reply all
Reply to author
Forward
0 new messages