Eric asked on Ask Autodesk about using Python to do vector math in Maya
is there a way to get all the vector math methods from mel eg.
vector $v = <<1.0,2.0,3.0>>;
mag $v;
this, cross products, matrix multiplications, etc. How do I do this in python? Can I do this in python; if not, what is the recommended way of doing all this?
Maya's Python does not come with any of the math tools that exist for MEL, so all the docs for the commands abs, angle, bessel, ceil, clamp, constrainValue, cos, cross, crossProduct, , deg_to_rad, delrandstr, dot, dotProduct , equivalent , equivalentTol , erf, exp, floatEq , floor, fmod, gamma, gauss, getLastError, getProcArguments, hermite, hsv_to_rgb, hypot, linstep, log, mag, max, min, noise, normalize , pointMatrixMult , pow, rad_to_deg, rand, randstate, rgb_to_hsv, rot, seed, sign, sin, smoothstep, sphrand, sqrt, tan, trunc, unit will say Only available in MEL
some of them are available from the math module, such as sin and cos, so you can do
import math
math.cos(60.0)
# Result: -0.952412980415 #
But not the vector functions like cross and dot, so we'll need to get those from somewhere else.
Recent Comments