C++ API Reference
MFloatVector Class Reference

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

#include <MFloatVector.h>

Public Member Functions

 MFloatVector ()
 The default class constructor. More...
 
 MFloatVector (const MFloatVector &)
 The copy constructor. More...
 
 MFloatVector (const MVector &)
 Class constructor. More...
 
 MFloatVector (const MFloatPoint &)
 Class constructor. More...
 
 MFloatVector (const MPoint &)
 Class constructor. More...
 
 MFloatVector (float xx, float yy, float zz=0.0)
 Class constructor. More...
 
 MFloatVector (const float f[3])
 Class constructor. More...
 
 MFloatVector (const double d[3])
 Class constructor. More...
 
 ~MFloatVector ()
 Class destructor.
 
MFloatVectoroperator= (const MFloatVector &src)
 The assignment operator. More...
 
float operator() (unsigned int i) const
 The index operator. More...
 
float operator[] (unsigned int i) const
 The index operator. More...
 
MFloatVector operator^ (const MFloatVector &right) const
 The cross product operator. More...
 
MFloatVectoroperator/= (float scalar)
 The in place division operator. More...
 
MFloatVector operator/ (float scalar) const
 The division operator. More...
 
MFloatVectoroperator*= (int scalar)
 The in place multiplication operator. More...
 
MFloatVectoroperator*= (short scalar)
 The in place multiplication operator. More...
 
MFloatVectoroperator*= (unsigned int scalar)
 The in place multiplication operator. More...
 
MFloatVectoroperator*= (unsigned short scalar)
 The in place multiplication operator. More...
 
MFloatVectoroperator*= (float scalar)
 The in place multiplication operator. More...
 
MFloatVectoroperator*= (double)
 The in place multiplication operator. More...
 
MFloatVector operator* (int scalar) const
 The multiplication operator. More...
 
MFloatVector operator* (short scalar) const
 The multiplication operator. More...
 
MFloatVector operator* (unsigned int scalar) const
 The multiplication operator. More...
 
MFloatVector operator* (unsigned short scalar) const
 The multiplication operator. More...
 
MFloatVector operator* (float scalar) const
 The multiplication operator. More...
 
MFloatVector operator* (double scalar) const
 The multiplication operator. More...
 
MFloatVector operator+ (const MFloatVector &other) const
 The vector addition operator. More...
 
MFloatVectoroperator+= (const MFloatVector &other)
 The in place vector addition operator. More...
 
MFloatVector operator- () const
 The unary minus operator. More...
 
MFloatVector operator- (const MFloatVector &other) const
 The vector subtraction operator. More...
 
MFloatVectoroperator-= (const MFloatVector &other)
 The in place vector subtraction operator. More...
 
MFloatVector operator* (const MFloatMatrix &) const
 The matrix multiplication operator.
 
MFloatVectoroperator*= (const MFloatMatrix &)
 The in place matrix multiplication operator.
 
float operator* (const MFloatVector &other) const
 The dot product operator. More...
 
bool operator!= (const MFloatVector &other) const
 The vector inequality operator. More...
 
bool operator== (const MFloatVector &other) const
 The vector equality operator. More...
 
MStatus get (float[3]) const
 Extracts the x, y, and z components of the vector and places them in elements 0, 1, and 2 of the float array passed. More...
 
float length () const
 
MFloatVector normal () const
 Computes a unit vector aligned to the vector. More...
 
MStatus normalize ()
 Performs an in place normalization of the vector. More...
 
float angle (const MFloatVector &other) const
 Returns the angle in radians between the vector and the one passed as an argument. More...
 
bool isEquivalent (const MFloatVector &other, float tolerance=MFloatVector_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 MFloatVector &other, float tolerance=MFloatVector_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...
 
float & operator() (unsigned int i)
 NO SCRIPT SUPPORT. More...
 
float & operator[] (unsigned int i)
 NO SCRIPT SUPPORT. More...
 
MFloatVector transformAsNormal (const MFloatMatrix &matrix) const
 NO SCRIPT SUPPORT. More...
 

Public Attributes

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

Static Public Attributes

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

Friends

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

Detailed Description

A vector math class for vectors of floats.

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:
anisotropicShader/anisotropicShader.cpp, apiDirectionalLightShape/apiDirectionalLightShape.cpp, apiMeshShape/apiMeshGeometryOverride.cpp, backfillShader/backfillShader.cpp, blindDataShader/blindDataShader.cpp, brickShader/brickShader.cpp, cellShader/cellShader.cpp, cgFx/cgfxShaderNode.cpp, checkerShader/checkerShader.cpp, clearcoat.cpp, compositingShader/compositingShader.cpp, contrastShader/contrastShader.cpp, customPrimitiveGenerator/customPrimitiveGenerator.cpp, depthShader/depthShader.cpp, displacementShader/displacementShader.cpp, dx11Shader/dx11Shader.cpp, dynExprField/dynExprField.cpp, fileTexture/fileTexture.cpp, flameShader/flameShader.cpp, footPrintNode_AnimatedMaterial/footPrintNode_GeometryOverride_AnimatedMaterial.cpp, gammaShader/gammaShader.cpp, geometryOverrideExample1/geometryOverrideExample1.cpp, geometryOverrideExample2/geometryOverrideExample2.cpp, geomShader/geomShader.cpp, glslShader/GLSLShader.cpp, gpuCache/CacheReaderAlembic.cpp, gpuCache/gpuCacheDrawOverride.cpp, gpuCache/gpuCacheUtil.h, hwPhongShader/hwPhongShader.cpp, interpShader/interpShader.cpp, intersectCmd/intersectCmd.cpp, lambertShader/lambertShader.cpp, lavaShader/lavaShader.cpp, lightShader/lightShader.cpp, meshOpCmd/meshOpFtyAction.cpp, meshOpCmd/polyModifierCmd.cpp, meshOpCmd/polyModifierCmd.h, mixtureShader/mixtureShader.cpp, noiseShader/noiseShader.cpp, objExport/objExport.cpp, onbShader/onbShader.cpp, phongShader/phongShader.cpp, sampleCmd/sampleCmd.cpp, sampleParticles/sampleParticles.cpp, shadowMatteShader/shadowMatteShader.cpp, shiftNode/shiftNode.cpp, simpleNoiseShader/simpleNoiseShader.cpp, slopeShader/slopeShaderNode.cpp, solidCheckerShader/solidCheckerShader.cpp, splitUVCmd/polyModifierCmd.cpp, splitUVCmd/polyModifierCmd.h, topologyTrackingNode/topologyTrackingNode.cpp, viewRenderOverride/viewRenderOverrideOperations.cpp, viewRenderOverridePointLightShadows/viewRenderOverridePointLightShadows.cpp, viewRenderOverrideShadows/viewRenderOverrideShadows.cpp, volumeShader/volumeShader.cpp, and vp2BlinnShader/vp2BlinnShader.cpp.

Constructor & Destructor Documentation

OPENMAYA_NAMESPACE_CLOSE OPENMAYA_MAJOR_NAMESPACE_OPEN MFloatVector ( )
inline

The default class constructor.

Creates a null vector.

MFloatVector ( const MFloatVector src)
inline

The copy constructor.

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

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

Class constructor.

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

Warning
This method converts double precision floating point values to single precision. This will result in a loss of precision and, if the double precision value exceeds the valid range for single precision, the result will be undefined and unusable.
Parameters
[in]srcthe vector object to copy
MFloatVector ( const MFloatPoint src)
inline

Class constructor.

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

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

Class constructor.

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

Warning
This method converts double precision floating point values to single precision. This will result in a loss of precision and, if the double precision value exceeds the valid range for single precision, the result will be undefined and unusable.
Parameters
[in]srcthe point object to copy
MFloatVector ( float  xx,
float  yy,
float  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.
MFloatVector ( 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.
MFloatVector ( const double  d[3])
inline

Class constructor.

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

Warning
This method converts double precision floating point values to single precision. This will result in a loss of precision and, if the double precision value exceeds the valid range for single precision, the result will be undefined and unusable.
Parameters
[in]dthe 3 element array containing the initial x, y, and z values.

Member Function Documentation

MFloatVector & operator= ( const MFloatVector src)
inline

The assignment operator.

Allows assignment between MFloatVectors.

Parameters
[in]srcThe vector to copy from.
Returns
A reference to the assigned vector.
float 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.
Returns
The vector component.
float 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.
Returns
The vector component.
MFloatVector operator^ ( const MFloatVector right) const
inline

The cross product operator.

Parameters
[in]rightVector to take the cross product with.
Returns
The cross product result.
MFloatVector & operator/= ( float  scalar)
inline

The in place division operator.

Parameters
[in]scalarDivision factor.
Returns
A reference to the scaled vector.
MFloatVector operator/ ( float  scalar) const
inline

The division operator.

Parameters
[in]scalarDivision factor.
Returns
The scaled vector.
MFloatVector & operator*= ( int  scalar)
inline

The in place multiplication operator.

Parameters
[in]scalarScale factor.
Returns
A reference to the scaled vector.
MFloatVector & operator*= ( short  scalar)
inline

The in place multiplication operator.

Parameters
[in]scalarScale factor.
Returns
A reference to the scaled vector.
MFloatVector & operator*= ( unsigned int  scalar)
inline

The in place multiplication operator.

Parameters
[in]scalarScale factor.
Returns
A reference to the scaled vector.
MFloatVector & operator*= ( unsigned short  scalar)
inline

The in place multiplication operator.

Parameters
[in]scalarScale factor.
Returns
A reference to the scaled vector.
MFloatVector & operator*= ( float  scalar)
inline

The in place multiplication operator.

Parameters
[in]scalarScale factor.
Returns
A reference to the scaled vector.
MFloatVector & operator*= ( double  scalar)
inline

The in place multiplication operator.

Parameters
[in]scalarScale factor.
Returns
A reference to the scaled vector.
MFloatVector operator* ( int  scalar) const
inline

The multiplication operator.

Parameters
[in]scalarScale factor.
Returns
The scaled vector.
MFloatVector operator* ( short  scalar) const
inline

The multiplication operator.

Parameters
[in]scalarScale factor.
Returns
The scaled vector.
MFloatVector operator* ( unsigned int  scalar) const
inline

The multiplication operator.

Parameters
[in]scalarScale factor.
Returns
The scaled vector.
MFloatVector operator* ( unsigned short  scalar) const
inline

The multiplication operator.

Parameters
[in]scalarScale factor.
Returns
The scaled vector.
MFloatVector operator* ( float  scalar) const
inline

The multiplication operator.

Parameters
[in]scalarScale factor.
Returns
The scaled vector.
MFloatVector operator* ( double  scalar) const
inline

The multiplication operator.

Parameters
[in]scalarScale factor.
Returns
The scaled vector.
MFloatVector operator+ ( const MFloatVector other) const
inline

The vector addition operator.

Parameters
[in]otherVector to add.
Returns
The resulting vector.
MFloatVector & operator+= ( const MFloatVector other)
inline

The in place vector addition operator.

Parameters
[in]otherVector to add.
Returns
A reference to the resulting vector.
MFloatVector operator- ( ) const
inline

The unary minus operator.

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

Returns
The resulting vector.
MFloatVector operator- ( const MFloatVector other) const
inline

The vector subtraction operator.

Parameters
[in]otherVector to substract.
Returns
The resulting vector.
MFloatVector & operator-= ( const MFloatVector other)
inline

The in place vector subtraction operator.

Parameters
[in]otherVector to substract.
Returns
A reference to the resulting vector.
float operator* ( const MFloatVector right) const
inline

The dot product operator.

Parameters
[in]rightVector take the dot product with.
Returns
Dot product value.
bool operator!= ( const MFloatVector other) const
inline

The vector inequality operator.

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

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

The vector equality operator.

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

Parameters
[in]otherVector to compare against.
Returns
Bool true if the vectors are identical and false otherwise.
MStatus get ( float  d[3]) const
inline

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

Parameters
[out]dThe array of 3 floats into which the results are placed.
Returns
MS::kSuccess if d is a non-zero pointer and MS::kFailure otherwise.
float length ( ) const
inline
Returns
The length of the vector.
MFloatVector normal ( ) const
inline

Computes a unit vector aligned to the vector.

Returns
The unit vector.
Examples:
sampleParticles/sampleParticles.cpp.
MStatus normalize ( )
inline
float angle ( const MFloatVector 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
bool isEquivalent ( const MFloatVector other,
float  tol = MFloatVector_kTol 
) const

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
true if the vectors are equivalent and false otherwise
bool isParallel ( const MFloatVector other,
float  tol = MFloatVector_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
float & 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.
Returns
Reference to the vector component.
float & 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.
Returns
Reference to the vector component.
MFloatVector transformAsNormal ( const MFloatMatrix matrix) const

NO SCRIPT SUPPORT.

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

Friends And Related Function Documentation

OPENMAYA_EXPORT MFloatVector operator* ( int  scalar,
const MFloatVector other 
)
friend

NO SCRIPT SUPPORT.

Parameters
[in]scalarmultiplication factor.
[in]otherVector to scale.
Returns
Scaled vector.
OPENMAYA_EXPORT MFloatVector operator* ( short  scalar,
const MFloatVector other 
)
friend

NO SCRIPT SUPPORT.

Parameters
[in]scalarmultiplication factor.
[in]otherVector to scale.
Returns
Scaled vector.
OPENMAYA_EXPORT MFloatVector operator* ( unsigned int  scalar,
const MFloatVector other 
)
friend

NO SCRIPT SUPPORT.

Parameters
[in]scalarmultiplication factor.
[in]otherVector to scale.
Returns
Scaled vector.
OPENMAYA_EXPORT MFloatVector operator* ( unsigned short  scalar,
const MFloatVector other 
)
friend

NO SCRIPT SUPPORT.

Parameters
[in]scalarmultiplication factor.
[in]otherVector to scale.
Returns
Scaled vector.
OPENMAYA_EXPORT MFloatVector operator* ( float  scalar,
const MFloatVector other 
)
friend

NO SCRIPT SUPPORT.

Parameters
[in]scalarmultiplication factor.
[in]otherVector to scale.
Returns
Scaled vector.
OPENMAYA_EXPORT MFloatVector operator* ( double  scalar,
const MFloatVector other 
)
friend

NO SCRIPT SUPPORT.

Parameters
[in]scalarmultiplication factor.
[in]otherVector to scale.
Returns
Scaled vector.
OPENMAYA_EXPORT MFloatVector operator* ( const MFloatMatrix left,
const MFloatVector right 
)
friend

NO SCRIPT SUPPORT.

Parameters
[in]leftthe matrix on the left
[in]rightthe matrix on the right
Returns
The MFloatVector resulting from the multiplication
OPENMAYA_EXPORT std::ostream& operator<< ( std::ostream &  os,
const MFloatVector v 
)
friend

NO SCRIPT SUPPORT.

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

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

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