C++ API Reference

A vector math class for vectors of doubles. More...

#include <MVector.h>

Public Types

enum  Axis { kXaxis, kYaxis, kZaxis, kWaxis }
 Axes. More...
 

Public Member Functions

 MVector ()
 The default class constructor. More...
 
 MVector (const MVector &)
 The copy constructor. More...
 
 MVector (const MFloatVector &)
 Class constructor. More...
 
 MVector (const MPoint &)
 Class constructor. More...
 
 MVector (const MFloatPoint &)
 Class constructor. More...
 
 MVector (double xx, double yy, double zz=0.0)
 Class constructor. More...
 
 MVector (const double d[3])
 Class constructor. More...
 
 MVector (const float f[3])
 Class constructor. More...
 
 ~MVector ()
 Class destructor.
 
MVectoroperator= (const MVector &src)
 The assignment operator. More...
 
double operator() (unsigned int i) const
 The index operator. More...
 
double operator[] (unsigned int i) const
 The index operator. More...
 
MVector operator^ (const MVector &right) const
 The cross product operator. More...
 
double operator* (const MVector &right) const
 The dot product operator. More...
 
MVectoroperator/= (double scalar)
 The in place division operator. More...
 
MVector operator/ (double scalar) const
 The division operator. More...
 
MVectoroperator*= (int scalar)
 The in place multiplication operator. More...
 
MVectoroperator*= (short scalar)
 The in place multiplication operator. More...
 
MVectoroperator*= (unsigned int scalar)
 The in place multiplication operator. More...
 
MVectoroperator*= (unsigned short scalar)
 The in place multiplication operator. More...
 
MVectoroperator*= (float scalar)
 The in place multiplication operator. More...
 
MVectoroperator*= (double scalar)
 The in place multiplication operator. More...
 
MVector operator* (int scalar) const
 The multiplication operator. More...
 
MVector operator* (short scalar) const
 The multiplication operator. More...
 
MVector operator* (unsigned int scalar) const
 The multiplication operator. More...
 
MVector operator* (unsigned short scalar) const
 The multiplication operator. More...
 
MVector operator* (float scalar) const
 The multiplication operator. More...
 
MVector operator* (double scalar) const
 The multiplication operator. More...
 
MVector operator+ (const MVector &other) const
 The vector addition operator. More...
 
MVectoroperator+= (const MVector &other)
 The in place vector addition operator. More...
 
MVector operator- () const
 The unary minus operator. More...
 
MVectoroperator-= (const MVector &other)
 The in place vector subtraction operator. More...
 
MVector operator- (const MVector &other) const
 The vector subtraction operator. More...
 
MVector operator* (const MMatrix &) const
 The matrix multiplication operator.
 
MVectoroperator*= (const MMatrix &)
 The in place matrix multiplication operator.
 
bool operator!= (const MVector &other) const
 The vector inequality operator. More...
 
bool operator== (const MVector &other) const
 The vector equality operator. More...
 
MVector rotateBy (double x, double y, double z, double w) const
 Returns the vector that represents the rotation of this vector by the given quaternion. More...
 
MVector rotateBy (const double rotXYZ[3], MTransformationMatrix::RotationOrder order) const
 Returns the vector that represents the rotation of this vector by the given XYZ rotational values, applied according to the given rotation order. More...
 
MVector rotateBy (MVector::Axis axis, const double angle) const
 Returns the vector that represents the rotation of this vector by the given angle about the given axis. More...
 
MVector rotateBy (const MQuaternion &) const
 Returns the vector that represents the rotation of this vector by the given quaternion. More...
 
MVector rotateBy (const MEulerRotation &) const
 Returns the vector that represents the rotation of this vector by the given euler rotation. More...
 
MQuaternion rotateTo (const MVector &) const
 Returns the quaternion that represents the rotation of this vector into the other vector about their mutually perpendicular axis. More...
 
MStatus get (double[3]) const
 Extracts the x, y, and z components of the vector and places them in elements 0, 1, and 2 of the double array passed. More...
 
double length () const
 Return the length of the vector.
 
MVector normal () const
 Return a normalized copy of this vector.
 
MStatus normalize ()
 Performs an in place normalization of the vector. More...
 
double angle (const MVector &other) const
 Returns the angle in radians between the vector and the one passed as an argument. More...
 
bool isEquivalent (const MVector &other, double tolerance=MVector_kTol) const
 Returns true if the vector and the one passed as an argument are equal to each other within the specified tolerance. More...
 
bool isParallel (const MVector &other, double tolerance=MVector_kTol) const
 Returns true if the current vector and the one passed as an argument are parallel to each other within the specified tolerance. More...
 
MVector transformAsNormal (const MMatrix &matrix) const
 This method treats the vector as a normal vector and returns a transformed copy of the vector. More...
 
double & operator() (unsigned int i)
 NO SCRIPT SUPPORT. More...
 
double & operator[] (unsigned int i)
 NO SCRIPT SUPPORT. More...
 

Public Attributes

double x
 The x component of the vector.
 
double y
 The y component of the vector.
 
double z
 The z component of the vector.
 

Static Public Attributes

static const MVector zero
 The null vector.
 
static const MVector one
 The vector <1,1,1>
 
static const MVector xAxis
 Unit vector in the positive x direction.
 
static const MVector yAxis
 Unit vector in the positive y direction.
 
static const MVector zAxis
 Unit vector in the positive z direction.
 
static const MVector xNegAxis
 Unit vector in the negative z direction.
 
static const MVector yNegAxis
 Unit vector in the negative z direction.
 
static const MVector zNegAxis
 Unit vector in the negative z direction.
 

Friends

OPENMAYA_EXPORT MVector operator* (const MMatrix &, const MVector &)
 NO SCRIPT SUPPORT. More...
 
OPENMAYA_EXPORT MVector operator* (int, const MVector &)
 NO SCRIPT SUPPORT. More...
 
OPENMAYA_EXPORT MVector operator* (short, const MVector &)
 NO SCRIPT SUPPORT. More...
 
OPENMAYA_EXPORT MVector operator* (unsigned int, const MVector &)
 NO SCRIPT SUPPORT. More...
 
OPENMAYA_EXPORT MVector operator* (unsigned short, const MVector &)
 NO SCRIPT SUPPORT. More...
 
OPENMAYA_EXPORT MVector operator* (float, const MVector &)
 NO SCRIPT SUPPORT. More...
 
OPENMAYA_EXPORT MVector operator* (double, const MVector &)
 NO SCRIPT SUPPORT. More...
 
OPENMAYA_EXPORT std::ostream & operator<< (std::ostream &os, const MVector &v)
 NO SCRIPT SUPPORT. More...
 

Detailed Description

A vector math class for vectors of doubles.

This class provides access to Maya's internal vector math library allowing vectors to be handled easily, and in a manner compatible with internal Maya data structures.

All methods that query the vector are threadsafe, all methods that modify the vector are not threadsafe.

Examples:
AbcBullet/AttributesWriter.cpp, AbcBullet/MayaTransformCollectionWriter.cpp, AbcExport/AttributesWriter.cpp, AbcExport/MayaMeshWriter.cpp, AbcExport/MayaPointPrimitiveWriter.cpp, AbcImport/MeshHelper.cpp, AbcImport/NodeIteratorVisitorHelper.cpp, AbcImport/NurbsSurfaceHelper.cpp, AbcImport/XformHelper.cpp, animInfoCmd/animInfoCmd.cpp, apiDirectionalLightShape/apiDirectionalLightShape.cpp, apiMeshShape/apiMeshCreator.cpp, apiMeshShape/apiMeshData.cpp, apiMeshShape/apiMeshGeometryOverride.cpp, apiMeshShape/apiMeshShape.cpp, apiMeshShape/apiMeshShapeUI.cpp, apiMeshShape/apiMeshSubSceneOverride.cpp, atomImportExport/atomFileUtils.cpp, buildRotationNode/buildRotationNode.cpp, cgFx/cgfxShaderNode.cpp, closestPointCmd/closestPointCmd.cpp, closestPointOnCurve/closestPointOnCurveCmd.cpp, closestPointOnCurve/closestPointOnCurveNode.cpp, closestPointOnCurve/closestTangentUAndDistance.cpp, closestPointOnCurve/closestTangentUAndDistance.h, closestPointOnNurbsSurfaceCmd/closestPointOnNurbsSurfaceCmd.cpp, componentScaleManip/componentScaleManip.cpp, constraintEvaluator/constraintEvaluator.cpp, customAttrManip/customAttrManip.cpp, dynExprField/dynExprField.cpp, dynExprField/dynExprField.h, footPrintManip/footPrintManip.cpp, geometryCacheConverter/geometryCacheBlockDVAData.cpp, geometryCacheConverter/geometryCacheBlockFVAData.cpp, geometrySurfaceConstraint/geometrySurfaceConstraint.cpp, gpuCache/CacheReaderAlembic.cpp, gpuCache/gpuCacheFrustum.h, gpuCache/gpuCacheIsectUtil.cpp, gpuCache/gpuCacheIsectUtil.h, gpuCache/gpuCacheShapeNode.cpp, gpuCache/gpuCacheShapeNode.h, gpuCache/gpuCacheSpatialGrid.cpp, gpuCache/gpuCacheSpatialGrid.h, gpuCache/gpuCacheSpatialGridWalker.cpp, gpuCache/gpuCacheSpatialGridWalker.h, gpuCache/gpuCacheSpatialSubdivision.cpp, gpuCache/gpuCacheSpatialSubdivision.h, grabUVMain.cpp, hairCollisionSolver/hairCollisionSolver.cpp, intersectOnNurbsSurfaceCmd/intersectOnNurbsSurfaceCmd.cpp, lepTranslator/lepTranslator.cpp, lineManip/lineManip.cpp, lineManip/manipulatorMath.cpp, lineManip/manipulatorMath.h, lineManipContainer/lineManipContainer.cpp, lineManipContainer/manipulatorMath.cpp, lineManipContainer/manipulatorMath.h, listRichSelectionCmd/listRichSelectionCmd.cpp, manipOverride/customTriadManip.cpp, manipOverride/customTriadManip.h, manipOverride/manipOverride.cpp, manipOverride/rockingTransform2.cpp, MayaPluginForSpreticle/spReticleLoc.cpp, meshOpCmd/meshOpFtyAction.cpp, motionPathNode/motionPathNode.cpp, moveManip/moveManip.cpp, moveNumericTool/moveNumericTool.cpp, moveTool/moveTool.cpp, narrowPolyViewer/narrowPolyViewer.cpp, ownerEmitter/ownerEmitter.cpp, ownerEmitter/ownerEmitter.h, particleAttrNode/particleAttrNode.cpp, particleSystemInfoCmd/particleSystemInfoCmd.cpp, pfxInfoCmd/pfxInfoCmd.cpp, pointManip/pointManip.cpp, pointOnMeshInfo/getPointAndNormal.cpp, pointOnMeshInfo/getPointAndNormal.h, pointOnMeshInfo/pointOnMeshCmd.cpp, pointOnMeshInfo/pointOnMeshInfoNode.cpp, pointOnSubdNode/pointOnSubdNode.cpp, rawfootPrintNode/rawfootPrintNode.cpp, richMoveCmd/richMoveCmd.cpp, rockingTransform/rockingTransform.cpp, rockingTransformCheck/rockingTransform.cpp, rotateManip/rotateManip.cpp, sampleCmd/sampleCmd.cpp, simpleEmitter/simpleEmitter.cpp, simpleEmitter/simpleEmitter.h, simpleEvaluationDraw/simpleEvaluationDraw.cpp, simpleFluidEmitter/simpleFluidEmitter.cpp, simpleSolverNode/simpleSolverNode.cpp, simpleSpring/simpleSpring.cpp, simpleSpring/simpleSpring.h, squareScaleManip/manipulatorMath.cpp, squareScaleManip/manipulatorMath.h, squareScaleManip/squareScaleManip.cpp, squareScaleManipContext/manipulatorMath.cpp, squareScaleManipContext/manipulatorMath.h, squareScaleManipContext/squareScaleManipContext.cpp, surfaceTwistCmd/surfaceTwistCmd.cpp, sweptEmitter/sweptEmitter.cpp, sweptEmitter/sweptEmitter.h, swissArmyManip/swissArmyManip.cpp, torusField/torusField.cpp, torusField/torusField.h, transformDrawNode/transformDrawNode.cpp, translateCmd/translateCmd.cpp, and uiDrawManager/uiDrawManager.cpp.

Member Enumeration Documentation

enum Axis

Axes.

Enumerator
kXaxis 

 

kYaxis 

 

kZaxis 

 

kWaxis 

 

Constructor & Destructor Documentation

OPENMAYA_NAMESPACE_CLOSE OPENMAYA_MAJOR_NAMESPACE_OPEN MVector ( )
inline

The default class constructor.

Creates a null vector.

MVector ( const MVector src)
inline

The copy constructor.

Create a new vector and initialize it to the same values as the given vector.

Parameters
[in]srcthe vector object to copy
MVector ( const MFloatVector src)
inline

Class constructor.

Create a new vector and initialize it to the same values as the given MFloatVector.

Parameters
[in]srcthe vector object to copy
MVector ( const MPoint src)
inline

Class constructor.

Create a new vector and initialize it to the same x, y, z values as the given MPoint.

Parameters
[in]srcthe point object to copy
MVector ( const MFloatPoint src)
inline

Class constructor.

Create a new vector and initialize it to the same x, y, z values as the given point.

Parameters
[in]srcthe point object to copy
MVector ( double  xx,
double  yy,
double  zz = 0.0 
)
inline

Class constructor.

Initializes the vector with the explicit x, y and z values provided as arguments.

Parameters
[in]xxthe x component of the vector
[in]yythe y component of the vector
[in]zzthe z component of the vector. Defaults to 0.0.
MVector ( const double  d[3])
inline

Class constructor.

Initializes the vector with the explicit x, y and z values provided in the given double array.

Parameters
[in]dthe 3 element array containing the initial x, y, and z values
MVector ( const float  f[3])
inline

Class constructor.

Initializes the vector with the explicit x, y and z values provided in the given float array.

Parameters
[in]fthe 3 element array containing the initial x, y, and z values

Member Function Documentation

MVector & operator= ( const MVector src)
inline

The assignment operator.

Allows assignment between MVectors.

Parameters
[in]srcVector to copy from.
double operator() ( unsigned int  i) const
inline

The index operator.

If its argument is 0 it will return the x component of the vector. If its argument is 1 it will return the y component of the vector. Otherwise it will return the z component of the vector.

Parameters
[in]ivalue indicating which component to return
double operator[] ( unsigned int  i) const
inline

The index operator.

If its argument is 0 it will return the x component of the vector. If its argument is 1 it will return the y component of the vector. Otherwise it will return the z component of the vector.

Parameters
[in]ivalue indicating which component to return
MVector operator^ ( const MVector right) const
inline

The cross product operator.

Parameters
[in]rightVector to take the cross product with.
double operator* ( const MVector right) const
inline

The dot product operator.

Parameters
[in]rightVector to take the dot product with.
MVector & operator/= ( double  scalar)
inline

The in place division operator.

Parameters
[in]scalarDivision factor.
MVector operator/ ( double  scalar) const
inline

The division operator.

Parameters
[in]scalarDivision factor.
MVector & operator*= ( int  scalar)
inline

The in place multiplication operator.

Parameters
[in]scalarScale factor.
MVector & operator*= ( short  scalar)
inline

The in place multiplication operator.

Parameters
[in]scalarScale factor.
MVector & operator*= ( unsigned int  scalar)
inline

The in place multiplication operator.

Parameters
[in]scalarScale factor.
MVector & operator*= ( unsigned short  scalar)
inline

The in place multiplication operator.

Parameters
[in]scalarScale factor.
MVector & operator*= ( float  scalar)
inline

The in place multiplication operator.

Parameters
[in]scalarScale factor.
MVector & operator*= ( double  scalar)
inline

The in place multiplication operator.

Parameters
[in]scalarScale factor.
MVector operator* ( int  scalar) const
inline

The multiplication operator.

Parameters
[in]scalarScale factor.
MVector operator* ( short  scalar) const
inline

The multiplication operator.

Parameters
[in]scalarScale factor.
MVector operator* ( unsigned int  scalar) const
inline

The multiplication operator.

Parameters
[in]scalarScale factor.
MVector operator* ( unsigned short  scalar) const
inline

The multiplication operator.

Parameters
[in]scalarScale factor.
MVector operator* ( float  scalar) const
inline

The multiplication operator.

Parameters
[in]scalarScale factor.
MVector operator* ( double  scalar) const
inline

The multiplication operator.

Parameters
[in]scalarScale factor.
MVector operator+ ( const MVector other) const
inline

The vector addition operator.

Parameters
[in]otherVector to add.
MVector & operator+= ( const MVector other)
inline

The in place vector addition operator.

Parameters
[in]otherVector to add.
MVector operator- ( ) const
inline

The unary minus operator.

Negates the value of each of the x, y, and z components of the vector.

MVector & operator-= ( const MVector other)
inline

The in place vector subtraction operator.

Parameters
[in]otherVector to subtract.
MVector operator- ( const MVector other) const
inline

The vector subtraction operator.

Parameters
[in]otherVector to substract.
bool operator!= ( const MVector other) const
inline

The vector inequality operator.

This returns false if all three of the x, y, and z components are identical.

Parameters
[in]otherThe vector to compare to.
Returns
Bool false if the vectors are identical and true otherwise.
bool operator== ( const MVector other) const
inline

The vector equality operator.

This returns true if all three of the x, y, and z components are identical.

Parameters
[in]otherThe vector to compare to.
Returns
Bool true if the vectors are identical and false otherwise.
MVector rotateBy ( double  x,
double  y,
double  z,
double  w 
) const

Returns the vector that represents the rotation of this vector by the given quaternion.

Parameters
[in]xThe x component of the quaternion.
[in]yThe y component of the quaternion.
[in]zThe z component of the quaternion.
[in]wThe w component of the quaternion.
Returns
The resulting vector.
Examples:
motionPathNode/motionPathNode.cpp.
MVector rotateBy ( const double  rotXYZ[3],
MTransformationMatrix::RotationOrder  order 
) const

Returns the vector that represents the rotation of this vector by the given XYZ rotational values, applied according to the given rotation order.

Parameters
[in]rotXYZArray containing the X, Y, and Z axis rotations, respectively.
[in]orderOrder in which to apply the XYZ components of the rotation.
Returns
The resulting vector.
MVector rotateBy ( MVector::Axis  axis,
const double  angle 
) const

Returns the vector that represents the rotation of this vector by the given angle about the given axis.

Parameters
[in]axisThe axis to rotate about.
[in]angleThe rotation angle about the axis.
Returns
The resulting vector.
MVector rotateBy ( const MQuaternion q) const

Returns the vector that represents the rotation of this vector by the given quaternion.

Parameters
[in]qThe quaternion rotation by which the vector will be rotated to produce the resulting vector.
Returns
The resulting vector.
MVector rotateBy ( const MEulerRotation e) const

Returns the vector that represents the rotation of this vector by the given euler rotation.

Parameters
[in]eThe euler rotation by which the vector will be rotated to produce the resulting vector.
Returns
The resulting vector.
MQuaternion rotateTo ( const MVector other) const

Returns the quaternion that represents the rotation of this vector into the other vector about their mutually perpendicular axis.

Parameters
[in]otherThe other vector into which this vector will be rotated to produce the resulting quaternion rotation.
Returns
The resulting quaternion.
MStatus get ( double  dest[3]) const
inline

Extracts the x, y, and z components of the vector and places them in elements 0, 1, and 2 of the double array passed.

Parameters
[out]destthe array of 3 doubles into which the results are placed.
Returns
MS::kSuccess if dest is a non-zero pointer and MS::kFailure otherwise.
Examples:
AbcImport/NodeIteratorVisitorHelper.cpp, and AbcImport/XformHelper.cpp.
double angle ( const MVector other) const

Returns the angle in radians between the vector and the one passed as an argument.

Parameters
[in]otherthe vector from which to compute the angle.
Returns
The angle in radians
Examples:
buildRotationNode/buildRotationNode.cpp, and simpleSolverNode/simpleSolverNode.cpp.
bool isEquivalent ( const MVector other,
double  tol = MVector_kTol 
) const
inline

Returns true if the vector and the one passed as an argument are equal to each other within the specified tolerance.

Parameters
[in]otherThe vector to compare to.
[in]tolThe tolerance to use during the comparison.
Returns
Bool true if the vectors are equivalent and false otherwise.
Examples:
moveNumericTool/moveNumericTool.cpp, and moveTool/moveTool.cpp.
bool isParallel ( const MVector other,
double  tol = MVector_kTol 
) const

Returns true if the current vector and the one passed as an argument are parallel to each other within the specified tolerance.

Parameters
[in]otherthe vector to compare to
[in]tolthe tolerance to use during the comparison
Returns
true if the vectors are parallel and false otherwise
MVector transformAsNormal ( const MMatrix matrix) const

This method treats the vector as a normal vector and returns a transformed copy of the vector.

Normal vectors are not transformed in the same way as position vectors or points. If this vector is treated as a normal vector then it needs to be transformed by post multiplying it by the inverse tanspose of the transformation matrix. This method will apply the proper transformation to the vector as if it were a normal.

Parameters
[in]matrixthe transformation matrix
Returns
The resulting transformed vector
double & operator() ( unsigned int  i)
inline

NO SCRIPT SUPPORT.

The index operator.

If its argument is 0 it will return the x component of the vector. If its argument is 1 it will return the y component of the vector. Otherwise it will return the z component of the vector.

Parameters
[in]ivalue indicating which component to return
double & operator[] ( unsigned int  i)
inline

NO SCRIPT SUPPORT.

The index operator.

If its argument is 0 it will return the x component of the vector. If its argument is 1 it will return the y component of the vector. Otherwise it will return the z component of the vector.

Parameters
[in]ivalue indicating which component to return

Friends And Related Function Documentation

OPENMAYA_EXPORT MVector operator* ( const MMatrix left,
const MVector right 
)
friend

NO SCRIPT SUPPORT.

An MVector is the result.

Parameters
[in]leftthe matrix on the left
[in]rightthe vector on the right
Returns
The MVector resulting from the multiplication
OPENMAYA_EXPORT MVector operator* ( int  scalar,
const MVector other 
)
friend

NO SCRIPT SUPPORT.

Parameters
[in]scalarScale factor.
[in]otherVector to scale.
Returns
The scales vector.
OPENMAYA_EXPORT MVector operator* ( short  scalar,
const MVector other 
)
friend

NO SCRIPT SUPPORT.

Parameters
[in]scalarScale factor.
[in]otherVector to scale.
Returns
The scales vector.
OPENMAYA_EXPORT MVector operator* ( unsigned int  scalar,
const MVector other 
)
friend

NO SCRIPT SUPPORT.

Parameters
[in]scalarScale factor.
[in]otherVector to scale.
Returns
The scales vector.
OPENMAYA_EXPORT MVector operator* ( unsigned short  scalar,
const MVector other 
)
friend

NO SCRIPT SUPPORT.

Parameters
[in]scalarScale factor.
[in]otherVector to scale.
Returns
The scales vector.
OPENMAYA_EXPORT MVector operator* ( float  scalar,
const MVector other 
)
friend

NO SCRIPT SUPPORT.

Parameters
[in]scalarScale factor.
[in]otherVector to scale.
Returns
The scales vector.
OPENMAYA_EXPORT MVector operator* ( double  scalar,
const MVector other 
)
friend

NO SCRIPT SUPPORT.

Parameters
[in]scalarScale factor.
[in]otherVector to scale.
Returns
The scales vector.
OPENMAYA_EXPORT std::ostream& operator<< ( std::ostream &  os,
const MVector v 
)
friend

NO SCRIPT SUPPORT.

The format used is [x, y, z].

Parameters
[in]osthe ostream to print to
[in]vthe MVector whose value is to be printed
Returns
The ostream reference, os, provided as the first parameter.

The documentation for this class was generated from the following files: