# MVector

## Constants

Name | Type | Description
--- | --- | ---
kTolerance | float | Default tolerance used for inexact comparisons.
Axis Identifiers
kXaxis | int |
kYaxis | int |
kZaxis | int |
kWaxis | int |
Common Vectors
kZeroVector | MVector | (0,0,0)
kOneVector | MVector | (1,1,1)
kXaxisVector | MVector | (1,0,0)
kYaxisVector | MVector | (0,1,0)
kZaxisVector | MVector | (0,0,1)
kXnegAxisVector | MVector | (-1,0,0)
kYnegAxisVector | MVector | (0,-1,0)
kZnegAxisVector | MVector | (0,0,-1)

## Static Methods

None.

## Static Attributes

None.

## Constructors

Signature | Parameters | Description
--- | --- | ---
MVector() |  | Default constructor. Returns a new MVector object initialized to the zero vector.
MVector(src) | src - MVector, MFloatVector, MPoint or MFloatPoint | Copy constructor. Returns a new MVector object whose x, y and z coordinates are set to the x, y and z coordinates of src.
MVector(seq) | seq - sequence of two or three floats | Returns a new MVector object whose x, y and z coordinates are set to the elements of seq. If the sequence only contains two values z will be set to 0.0.
MVector(x, y, z=0.0) | x - float y - float z - float | Returns a new MVector object with the specified x, y and z coordinates.

## Object Methods

Signature | Parameters | Returns | Description
--- | --- | --- | ---
angle(other) | other - MVector | float | Returns the angle, in radians, between this vector and other.
isEquivalent(other, tolerance=kTolerance) | other - MVector tolerance - float | bool | Returns True if this vector and other are within the given tolerance of being equal.
isParallel(other, tolerance=kTolerance) | other - MVector tolerance - float | bool | Returns True if this vector and other are within the given tolerance of being parallel.
length() |  | float | Returns the magnitude of this vector.
normal() |  | MVector | Returns a new vector containing the normalized version of this vector.
normalize() |  | MVector | Normalizes this vector in-place and returns a new reference to it.
rotateBy(rot) | rot - MQuaternion or MEulerRotation | MVector | Returns a new vector containing the result of rotating this vector by the rotation given by rot.
rotateBy(axis, angle) | axis - Axis identifier constant angle - float | MVector | Returns a new vector containing the result of rotating this vector by angle radians about the specified axis.
rotateTo(target) | target - MVector | MQuaternion | Returns the quaternion which will rotate this vector into the target vector, about their mutually perpendicular axis.
transformAsNormal(matrix) | matrix - MMatrix | MVector | Returns a new vector which is calculated by postmultiplying this vector by the transpose of matrix's inverse and then normalizing it.

## Object Attributes

Name | Type | Access | Description
--- | --- | --- | ---
x | float | RW | X component.
y | float | RW | Y component.
z | float | RW | Z component.

## Sequence Support

An MVector is treated a sequence of three float values: [x, y, z].

len() returns 3.

Indexing and element assignment are supported.

Deletion, concatenation, repetition and slicing are not supported.

## Number Support

Operation | Description
--- | ---
MVector = MVector ^ MVector | New vector which is the cross product of the two vectors.
float = MVector * MVector | Dot product of the two vectors.
MVector = MVector / scalar | New vector whose components are those of the given vector, each divided by scalar, which can be of any type which is convertable to float.
MVector /= scalar | Divides each component of the vector by scalar, which can be of any type which is convertable to float, and returns a new reference to the vector.
MVector = MVector * scalar | New vector whose components are those of the given vector, each multiplied by scalar, which can be of any type which is convertable to float.
MVector = scalar * MVector | New vector whose components are those of the given vector, each multiplied by scalar, which can be of any type which is convertable to float.
MVector *= scalar | Multiplies each component of the vector by scalar, which can be of any type which is convertable to float, and returns a new reference to the vector.
MVector = MVector * MMatrix | New vector resulting from postmultiplying the vector by the matrix.
MVector = MMatrix * MVector | New vector resulting from premultiplying the vector by the matrix.
MVector *= MMatrix | Postmultiplies the vector by the matrix and returns a new reference to the vector.
MVector = MVector + MVector | New vector which is the sum of the two vectors.
MVector += MVector | Adds the second vector to the first and returns a new reference to the first.
MVector = -MVector | New vector which is the negative if the given vector.
MVector = MVector - MVector | New vector which is the difference of the two vectors.
MVector -= MVector | Subtracts the second vector from the first and returns a new reference to the first.

## Comparison Support

MVector == MVector | Returns True if each component of the first vector is exactly equal to the corresponding component of the second.
MVector != MVector | Returns False is any component of the first vector is not exactly equal to the corresponding component of the second.

All other comparison operators will raise a TypeError exception.

© 2011 Autodesk, Inc. All rights reserved.