class MVector

Jump to documentation

A vector math class for vectors of doubles. (OpenMaya) (OpenMaya.py)

public members:

enum Axis
kXaxis
kYaxis
kZaxis
kWaxis
MVector ()
MVector ( const MVector &)
MVector ( const MFloatPoint &)
MVector ( const MFloatVector &)
MVector ( const MPoint &)
MVector ( double xx, double yy, double zz = 0.0)
MVector ( const double[3] )
~MVector ()
MVector & operator= ( const MVector & src )
double operator() ( unsigned int i ) const
double operator[] ( unsigned int i )const
MVector operator^ ( const MVector & right) const
double operator* ( const MVector & right ) const
MVector & operator/= ( double scalar )
MVector operator/ ( double scalar ) const
MVector & operator*= ( double scalar )
MVector operator* ( double scalar ) const
MVector operator+ ( const MVector & other) const
MVector & operator+= ( const MVector & other )
MVector operator- () const
MVector & operator-= ( const MVector & other )
MVector operator- ( const MVector & other ) const
MVector operator* ( const MMatrix &) const
MVector & operator*= ( const MMatrix &)
bool operator!= ( const MVector & other ) const
bool operator== ( const MVector & other ) const
MVector rotateBy ( double x , double y , double z , double w) const
MVector rotateBy ( const double rotXYZ[3], MTransformationMatrix::RotationOrder order ) const
MVector rotateBy ( MVector::Axis axis, const double angle ) const
MVector rotateBy ( const MQuaternion & ) const
MVector rotateBy ( const MEulerRotation & ) const
MQuaternion rotateTo ( const MVector & ) const
MStatus get ( double[3] ) const
double length () const
MVector normal () const
MStatus normalize ()
double angle ( const MVector & other ) const
bool isEquivalent ( const MVector & other, double tolerance = MVector_kTol ) const
bool isParallel ( const MVector & other, double tolerance = MVector_kTol ) const
MVector transformAsNormal ( const MMatrix & matrix ) const
double& operator() ( unsigned int i )
NO SCRIPT SUPPORT
double& operator[] ( unsigned int i )
NO SCRIPT SUPPORT
friend MVector operator* ( const MMatrix &, const MVector &)
NO SCRIPT SUPPORT
friend MVector operator* ( int, const MVector &)
NO SCRIPT SUPPORT
friend MVector operator* ( short, const MVector &)
NO SCRIPT SUPPORT
friend MVector operator* ( unsigned int, const MVector &)
NO SCRIPT SUPPORT
friend MVector operator* ( unsigned short, const MVector &)
NO SCRIPT SUPPORT
friend MVector operator* ( float, const MVector &)
NO SCRIPT SUPPORT
friend MVector operator* ( double, const MVector &)
NO SCRIPT SUPPORT
friend std::ostream& operator<< (std::ostream& os, const MVector & v)
NO SCRIPT SUPPORT
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
double x
The x component of the vector
double y
The y component of the vector
double z
The z component of the vector

Documentation

This class provides access to Maya's vector math library.
Description

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.

Functions

MVector:: MVector ()

Description

The default class constructor. Creates a null vector.

MVector:: MVector (const MVector & src)

Description

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

Arguments

  • src the vector object to copy

MVector:: MVector (const MFloatPoint & src)

Description

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

Arguments

  • src the point object to copy

MVector:: MVector (const MFloatVector & src)

Description

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

Arguments

  • src the vector object to copy

MVector:: MVector (const MPoint & src)

Description

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

Arguments

  • src the point object to copy

MVector:: MVector (double xx, double yy, double zz)

Description

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

Arguments

  • xx the x component of the vector
  • yy the y component of the vector
  • zz the z component of the vector. Defaults to 0.0.

MVector:: MVector ( const double d[3] )

Description

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

Arguments

  • d the 3 element array containing the initial x, y, and z values

MVector:: ~MVector ()

Description

Class destructor.

MVector & MVector:: operator= (const MVector & src)

Description

The assignment operator. Allows assignment between MVectors.

double& MVector:: operator() ( unsigned int i )

Description

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.

Arguments

  • i value indicating which component to return

double MVector:: operator() ( unsigned int i ) const

Description

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.

Arguments

  • i value indicating which component to return

double& MVector:: operator[] ( unsigned int i )

Description

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.

Arguments

  • i value indicating which component to return

double MVector:: operator[] ( unsigned int i ) const

Description

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.

Arguments

  • i value indicating which component to return

MVector MVector:: operator^ (const MVector & right) const

Description

The cross product operator.

double MVector:: operator* (const MVector & right) const

Description

The dot product operator.

MVector & MVector:: operator*= (double scalar)

Description

The in place multiplication operator.

MVector MVector:: operator* ( double scalar ) const

Description

The multiplication operator.

MVector operator * (int scalar, const MVector & other)

Description

The multiplication operator that allows the scalar value to preceed the vector.

MVector operator * (short scalar, const MVector & other)

Description

The multiplication operator that allows the scalar value to preceed the vector.

MVector operator * (unsigned int scalar, const MVector & other)

Description

The multiplication operator that allows the scalar value to preceed the vector.

MVector operator * (unsigned short scalar, const MVector & other)

Description

The multiplication operator that allows the scalar value to preceed the vector.

MVector operator * (float scalar, const MVector & other)

Description

The multiplication operator that allows the scalar value to preceed the vector.

MVector operator * (double scalar, const MVector & other)

Description

The multiplication operator that allows the scalar value to preceed the vector.

MVector & MVector:: operator/= (double scalar)

Description

The in place division operator.

MVector MVector:: operator/ ( double scalar ) const

Description

The division operator.

MVector MVector:: operator- (const MVector & other) const

Description

The vector subtraction operator.

MVector MVector:: operator+ (const MVector & other) const

Description

The vector addition operator.

MVector & MVector:: operator+= (const MVector & other)

Description

The in place vector addition operator.

MVector MVector:: operator- () const

Description

The unary minus operator. Negates the value of each of the x, y, and z components of the vector.

MVector & MVector:: operator-= (const MVector & other)

Description

The in place vector subtraction operator.

MVector MVector:: operator* (const MMatrix & right) const

Description

The matrix multiplication operator.

MVector & MVector:: operator *= (const MMatrix & right)

Description

The in place matrix multiplication operator.

MVector operator* (const MMatrix & left, const MVector & right)

Description

The multiplication operator that allows the MMatrix on the left to be multiplied by an MVector on the right. An MVector is the result.

Arguments

  • left the matrix on the left
  • right the vector on the right

Return Value

  • the MVector resulting from the multiplication

bool MVector:: operator== (const MVector & other) const

Description

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

Return Value

  • bool true if the vectors are identical and false otherwise

bool MVector:: operator!= (const MVector & other) const

Description

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

Return Value

  • bool false if the vectors are identical and true otherwise

MStatus MVector:: get ( double dest[3] ) const

Description

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

Arguments

  • d the array of 3 doubles into which the results are placed.

Return Value

  • MS::kSuccess if dest is a non-zero pointer and MS::kFailure otherwise

double MVector:: length () const

Description

Return the length of the vector.

MVector MVector:: normal () const

Description

Return a normalized copy of this vector.

MStatus MVector:: normalize ()

Description

Performs an in place normalization of the vector

Return Value

  • always returns MS::kSuccess

double MVector:: angle (const MVector & other) const

Description

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

Arguments

  • other the vector from which to compute the angle.

Return Value

  • the angle in radians

bool MVector:: isEquivalent (const MVector & other, double tol) const

Description

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

Arguments

  • other the vector to compare to
  • tol the tolerance to use during the comparison

Return Value

  • bool true if the vectors are equivalent and false otherwise

bool MVector:: isParallel (const MVector & other, double tol) const

Description

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

Arguments

  • other the vector to compare to
  • tol the tolerance to use during the comparison

Return Value

  • bool true if the vectors are parallel and false otherwise

MVector MVector:: rotateBy (double x , double y , double z , double w) const

Description

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

Arguments

  • x The x component of the quaternion.
  • y The y component of the quaternion.
  • z The z component of the quaternion.
  • w The w component of the quaternion.

Return Value

  • The resulting vector.

MVector MVector:: rotateBy ( const double rotXYZ[3], MTransformationMatrix::RotationOrder order ) const

Description

Returns the vector that represents the rotation of this vector by the given rotateXYZ according to the rotation order.

Arguments

  • rotXYZ The array that represent the rotation about the X, Y, and Z axis respectively.

Return Value

  • The resulting vector.

MVector MVector:: rotateBy ( MVector::Axis axis, const double angle ) const

Description

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

Arguments

  • axis The axis to rotate about.
  • angle The rotation angle about the axis.

Return Value

  • The resulting vector.

MVector MVector:: rotateBy ( const MQuaternion &q ) const

Description

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

Arguments

  • q The quaternion rotation by which the vector will be rotated to produce the resulting vector.

Return Value

  • The resulting vector.

MVector MVector:: rotateBy ( const MEulerRotation &e ) const

Description

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

Arguments

  • e The euler rotation by which the vector will be rotated to produce the resulting vector.

Return Value

  • The resulting vector.

MQuaternion MVector:: rotateTo ( const MVector &other ) const

Description

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

Arguments

  • other The other vector into which this vector will be rotated to produce the resulting quaternion rotation.

Return Value

  • The resulting quaternion.

MVector MVector:: transformAsNormal ( const MMatrix & matrix ) const

Description

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.

Arguments

  • matrix the transformation matrix

Return Value

  • The resulting transformed vector

std::ostream& operator<< ( std::ostream& os, const MVector & v )

Description

Print the contents of the given MVector on the given ostream. The format used is [x, y, z].

Arguments

  • os the ostream to print to
  • v the MVector whose value is to be printed

Return Value

  • the ostream reference, os, provided as the first parameter.

This class has no child classes.


Autodesk® Maya® 2008 © 1997-2007 Autodesk, Inc. All rights reserved. doc++ Copyright