Vector Array CommandsAboutThis functionset gives you all the commands you already know from mel (+ a few extras) wrapped so they work with arrays. Vector arrays are frequently used throughout Maya (eg. in particle systems or deformers) and being able to handle them efficiently, greatly reduces the amount of mel work needed to do something useful with them. Important conventionsA mVector in melfunctions is represented as an array of 3 floats. All commands don’t change the actual data in place, but create a new output. Summary | This functionset gives you all the commands you already know from mel (+ a few extras) wrapped so they work with arrays. | | | | | | Get number of vectors in a vector array | | Append elements to the end of a vector array | | Get elements from a vector array | | Set elements in a vector array, this function will not grow the vector array, but error when you try to set an invalid array element! | | Add two vector arrays together elementwise | | Subtract two vector arrays elementwise | | The dot product of two vector arrays elementwise | | Cross product of two vector arrays elementwise | | Multiply componentwise two vector arrays together | | Multiplication of vector and double | | Division of vector and double | | The negate vector of an array | | Multiplication of vector and matrix, the way to transform a vector between differnt spaces | | The normalized vector of an array | | | | Distance between two vector position arrays elementwise | | Angle between two vector arrays elementwise | | Rotate vector by euler angles, euler angles are assumed to be in xyz rotation order | | Rotate vector by defining an axis to rotate about and an angle (in rad) | | Check if two mVectors are exactly equal | | Check if two mVectors are not equal | | Check if elements of two vector arrays are equivalent within a tolerance | | Get the length of the elements of a vector array. | | Get the sqr length of the elements of a vector array. | | linear interpolation of two vectors | | spherical linear interpolation of two vectors | | Get vector component X within a vector array. | | Get vector component Y within a vector array. | | Get vector component Z within a vector array. | | Get vector component at specified poistion within a vector array. | | | | | | | | Set vector component at specified poistion within a vector array. |
mVecCreate| #define mel mVecCreate( | int | $count, | | float | $template[3] | ) |
|
Create a vector array Parameters| none | return the null vector or | | count | return count null vectors or | | count | the number of vector elements to create | | template | the template vector which will be used for creation |
ReturnsThe vector array as a float array of its elements
mVecSize| #define mel int mVecSize( | float | $vectorArrayA[] | ) |
|
Get number of vectors in a vector array Parameters| vectorArrayA | vector array Returns: |
The size of the vector array
mVecAppend| #define mel mVecAppend( | float | $vectorArrayA[], | | float | $vectorArrayB[] | ) |
|
Append elements to the end of a vector array Parameters| vectorArrayA | vector array to extract elements to | | vectorArrayB | vector array to append Returns: |
The new vector array of as a float array of its elements
mVecGet| #define mel mVecGet( | float | $vectorArrayA[], | | int | $id[], | | float | $vectorArrayB[] | ) |
|
Get elements from a vector array Parameters| vectorArrayA | vector array to extract elements from | | ids | int array of ids to extraxt from the vector array optional | | vectorArrayB | vector array that will be used as a substitution if an id does not exist in array A, must be 1 or same size than id array Returns: |
The vector array of as a float array of its elements
mVecSet| #define mel mVecSet( | float | $vectorArrayA[], | | int | $id[], | | float | $vectorArrayB[] | ) |
|
Set elements in a vector array, this function will not grow the vector array, but error when you try to set an invalid array element! Parameters| vectorArrayA | base vector array | | ids | int array of ids defining where in A to insert B | | vectorArrayB | vector array of elements to be inserted into A, must be size 1 or same size than id array Returns: |
The vector arrayA with elements inserted of of as a float array of its elements
mVecAdd| #define mel mVecAdd( | float[] | $vecArrayA, | | float[] | $vecArrayB | ) |
|
Add two vector arrays together elementwise Parameters| $vecArrayA | the first vector array | | $vecArrayB | the second vector array |
Returns$vecArrayA + $vecArrayB, the sum of the two vector arrays elementswise as a float[]
mVecSub| #define mel mVecSub( | float[] | $vecArrayA, | | float[] | $vecArrayB | ) |
|
Subtract two vector arrays elementwise Parameters| $vecArrayA | the first vector array | | $vecArrayB | the second vector array |
Returns| $vecArrayA | $vecArrayB, the difference of the two vector arrays elementswise as a float[] |
mVecDot| #define mel mVecDot( | float[] | $vecArrayA, | | float[] | $vecArrayB | ) |
|
The dot product of two vector arrays elementwise Parameters| $vecArrayA | the first vector array | | $vecArrayB | the second vector array |
Returns$vecArrayA * $vecArrayB, the dot product of the two vector arrays elementswise as a float[]
mVecCross| #define mel mVecCross( | float[] | $vecArrayA, | | float[] | $vecArrayB | ) |
|
Cross product of two vector arrays elementwise Parameters| $vecArrayA | the first vector array | | $vecArrayB | the second vector array |
Returns$vecArrayA ^ $vecArrayB, the cross product of the two vector arrays elementswise as a float[]
mVecMult| #define mel mVecMult( | float[] | $vecArrayA, | | float[] | $vecArrayB | ) |
|
Multiply componentwise two vector arrays together Parameters| $vecArrayA | the first vector array | | $vecArrayB | the second vector array |
Returns$vecArrayA.x * $vecArrayB.x, $vecArrayA.y * $vecArrayB.y, $vecArrayA.z * $vecArrayB.z, the component produkt of the two vector arrays as a float[]
mVecDblMult| #define mel mVecDblMult( | float[] | $vecArrayA, | | float[] | $vecArrayB | ) |
|
Multiplication of vector and double Parameters| $vecArrayA | the vector array | | $dblArrayB | the double array |
Returns$vecArrayA * $dblArrayB, the product of the two arrays as a float[]
mVecDblDiv| #define mel mVecDblDiv( | float[] | $vecArrayA, | | float[] | $vecArrayB | ) |
|
Division of vector and double Parameters| $vecArrayA | the vector array | | $dblArrayB | the double array |
Returns$vecArrayA / $dblArrayB, the product of the two arrays as a float[]
mVecNegate| #define mel mVecNegate( | float[] | $vecArrayA | ) |
|
The negate vector of an array Parameters| $vecArrayA | the vector array |
Returns-($vecArrayA) , the negated vectors in an array as a float[]
mVecMatMult| #define mel mVecMatMult( | float[] | $vecArrayA, | | float[] | $matArrayB | ) |
|
Multiplication of vector and matrix, the way to transform a vector between differnt spaces Parameters| $vecArrayA | the vector array | | $matArrayB | the matrix array |
Returns$vecArrayA * $matArrayB, the product of the two arrays as a float[]
mVecNormal| #define mel mVecNormal( | float[] | $vecArrayA | ) |
|
The normalized vector of an array Parameters| $vecArrayA | the vector array |
Returnsnorm($vecArrayA) , the normalized vectors in an array as a float[]
mVecSetLength| #define mel mVecSetLength( | float[] | $vecArrayA, | | float[] | $vecArrayB | ) |
|
Set length of vector Parameters| $vecArrayA | the vector array | | $dblArrayB | the double array |
Returns$vecArrayA * $dblArrayB, the product of the two arrays as a float[]
mVecDistance| #define mel mVecDistance( | float[] | $vecArrayA, | | float[] | $vecArrayB | ) |
|
Distance between two vector position arrays elementwise Parameters| $vecArrayA | the first vector array | | $vecArrayB | the second vector array |
Returnsthe distance between the two vector arrays elementswise as a float[]
mVecAngle| #define mel mVecAngle( | float[] | $vecArrayA, | | float[] | $vecArrayB | ) |
|
Angle between two vector arrays elementwise Parameters| $vecArrayA | the first vector array | | $vecArrayB | the second vector array |
Returnsthe angle between the two vector arrays elementswise in rad as a float[]
mVecRotateByEuler| #define mel mVecRotateByEuler( | float[] | $vecArrayA, | | float[] | $vecArrayB | ) |
|
Rotate vector by euler angles, euler angles are assumed to be in xyz rotation order Parameters| $vecArrayA | the first vector array | | $vecArrayB | the second vector array of euler angles |
Returnsthe first vector rotate by the euler angles a float[]
mVecRotateByAxisAngle| #define mel mVecRotateByAxisAngle( | float[] | $vecArrayA, | | float[] | $vecArrayB | ) |
|
Rotate vector by defining an axis to rotate about and an angle (in rad) Parameters| $vecArrayA | the first vector | | $vecArrayB | the axis | | $dblArrayC | the angle |
Returnsthe first vector rotated about the axis by the angle as a float[]
mVecIsEqual| #define mel mVecIsEqual( | float[] | $vecArrayA, | | float[] | $vecArrayB | ) |
|
Check if two mVectors are exactly equal Parameters| $vecArrayA | the first vector array | | $vecArrayB | the second vector array |
Returns$vecArrayA == $vecArrayB, the result of the elementwise comparison as a float[] of (0,1)
mVecIsNotEqual| #define mel mVecIsNotEqual( | float[] | $vecArrayA, | | float[] | $vecArrayB | ) |
|
Check if two mVectors are not equal Parameters| $vecArrayA | the first vector array | | $vecArrayB | the second vector array |
Returns$vecArrayA != $vecArrayB, the result of the elementwise comparison as a float[] of (0,1)
mVecIsEquivalent| #define mel mVecIsEquivalent( | float[] | $vecArrayA, | | float[] | $vecArrayB | ), float[] $toleranceArray) |
|
Check if elements of two vector arrays are equivalent within a tolerance Parameters| $vecArrayA | the first matrix array | | $vecArrayB | the second matrix array | | $toleranceArray | the maximum amount of error allowed |
Returnsthe result of the comparison as a float array of (0,1)
mVecLength| #define mel mVecLength( | float[] | $vecArrayA | ) |
|
Get the length of the elements of a vector array. Parameters| $vecArrayA | the vector array |
Returnsthe lengths of the vectors as a float[]
mVecLengthSqr| #define mel mVecLengthSqr( | float[] | $vecArrayA | ) |
|
Get the sqr length of the elements of a vector array. If you only need this length for comparison reasons it is faster to compare the sqr(v) as this save you to take the sqrt! Parameters| $vecArrayA | the vector array |
Returnsthe sqr lengths of the vectors as a float[]
mVecLerp| #define mel mVecLerp( | float[] | $vecArrayA, | | float[] | $vecArrayB, | | float[] | $param | ) |
|
linear interpolation of two vectors Parameters| $vecArrayA | the first vector array | | $vecArrayB | the second vector array | | $param | the interpolation parameter [0-1] (will be clamped) |
Returnsthe interpolated vector array as a float array of (0,1)
mVecSlerp| #define mel mVecSlerp( | float[] | $vecArrayA, | | float[] | $vecArrayB, | | float[] | $param | ) |
|
spherical linear interpolation of two vectors Parameters| $vecArrayA | the first vector array | | $vecArrayB | the second vector array | | $param | the interpolation parameter [0-1] (will be clamped) |
Returnsthe interpolated vector array as a float array of (0,1)
mVecGetX| #define mel mVecGetX( | float | $vecArrayA[] | ) |
|
Get vector component X within a vector array. Parameters| $vecArrayA | the vector array |
Returnsthe elements at $vec.x as a float array
mVecGetY| #define mel mVecGetY( | float | $vecArrayA[] | ) |
|
Get vector component Y within a vector array. Parameters| $vecArrayA | the vector array |
Returnsthe elements at $vec.y as a float array
mVecGetZ| #define mel mVecGetZ( | float | $vecArrayA[] | ) |
|
Get vector component Z within a vector array. Parameters| $vecArrayA | the vector array |
Returnsthe elements at $vec.z as a float array
mVecGetComponent| #define mel mVecGetComponent( | float | $vecArrayA[], | | int | $component[] | ) |
|
Get vector component at specified poistion within a vector array. Parameters| $vecArrayA | the vector array | | $component | the index [0-2] as an int array |
Returnsthe element at $vec[$component] as a float array
mVecSetX| #define mel mVecSetX( | float | $vecArrayA[], | | float | $value[] | ) |
|
Set vector component X Parameters| $vecArrayA | the vector array | | $value | the double array to be set into the component |
Returnsthe vector array with the inserted as a float array
mVecSetY| #define mel mVecSetY( | float | $vecArrayA[], | | float | $value[] | ) |
|
Set vector component X Parameters| $vecArrayA | the vector array | | $value | the double array to be set into the component |
Returnsthe vector array with the inserted as a float array
mVecSetZ| #define mel mVecSetZ( | float | $vecArrayA[], | | float | $value[] | ) |
|
Set vector component X Parameters| $vecArrayA | the vector array | | $value | the double array to be set into the component |
Returnsthe vector array with the inserted as a float array
mVecSetComponent| #define mel mVecSetComponent( | float | $vecArrayA[], | | int | $component[], | | float | $value[] | ) |
|
Set vector component at specified poistion within a vector array. Parameters| $vecArrayA | the vector array | | $component | the index [0-2] as an int array | | $value | the double array to be set into the component |
Returnsthe vector array with the inserted as a float array
|