Class XMVector3
The 3D vector functions provided by DirectXMath.
Inherited Members
Namespace: JeremyAnsel.DirectX.DXMath
Assembly: JeremyAnsel.DirectX.DXMath.dll
Syntax
public static class XMVector3
Methods
| Edit this page View SourceAngleBetweenNormals(XMVector, XMVector)
Computes the radian angle between two normalized 3D vectors.
Declaration
public static XMVector AngleBetweenNormals(XMVector n1, XMVector n2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | n1 | The first normalized vector. |
XMVector | n2 | The second normalized vector. |
Returns
Type | Description |
---|---|
XMVector | Returns a vector. The radian angle between N1 and N2 is replicated to each of the components. |
AngleBetweenNormalsEst(XMVector, XMVector)
Estimates the radian angle between two normalized 3D vectors.
Declaration
public static XMVector AngleBetweenNormalsEst(XMVector n1, XMVector n2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | n1 | The first normalized vector. |
XMVector | n2 | The second normalized vector. |
Returns
Type | Description |
---|---|
XMVector | Returns a vector. The estimate of the radian angle (between N1 and N2) is replicated to each of the components. |
AngleBetweenVectors(XMVector, XMVector)
Computes the radian angle between two 3D vectors.
Declaration
public static XMVector AngleBetweenVectors(XMVector v1, XMVector v2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v1 | The first vector. |
XMVector | v2 | The second vector. |
Returns
Type | Description |
---|---|
XMVector | Returns a vector. The radian angle between V1 and V2 is replicated to each of the components. |
ClampLength(XMVector, float, float)
Clamps the length of a 3D vector to a given range.
Declaration
public static XMVector ClampLength(XMVector v, float lengthMin, float lengthMax)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The vector. |
float | lengthMin | The minimum clamp length. |
float | lengthMax | The maximum clamp length. |
Returns
Type | Description |
---|---|
XMVector | Returns a 3D vector whose length is clamped to the specified minimum and maximum. |
ClampLengthV(XMVector, XMVector, XMVector)
Clamps the length of a 3D vector to a given range.
Declaration
public static XMVector ClampLengthV(XMVector v, XMVector lengthMin, XMVector lengthMax)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The vector. |
XMVector | lengthMin | A 3D vector whose x, y, and z-components are equal to the minimum clamp length. The x, y, and z-components must be greater-than-or-equal to zero. |
XMVector | lengthMax | A 3D vector whose x, y, and z-components are equal to the maximum clamp length. The x, y, and z-components must be greater-than-or-equal to zero. |
Returns
Type | Description |
---|---|
XMVector | Returns a 3D vector whose length is clamped to the specified minimum and maximum. |
ComponentsFromNormal(out XMVector, out XMVector, XMVector, XMVector)
Using a reference normal vector, splits a 3D vector into components that are parallel and perpendicular to the normal.
Declaration
public static void ComponentsFromNormal(out XMVector parallel, out XMVector perpendicular, XMVector v, XMVector normal)
Parameters
Type | Name | Description |
---|---|---|
XMVector | parallel | The component of V that is parallel to Normal. |
XMVector | perpendicular | The component of V that is perpendicular to Normal. |
XMVector | v | The vector to break into components. |
XMVector | normal | The reference normal vector. |
Cross(XMVector, XMVector)
Computes the cross product between two 3D vectors.
Declaration
public static XMVector Cross(XMVector v1, XMVector v2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v1 | The first vector. |
XMVector | v2 | The second vector. |
Returns
Type | Description |
---|---|
XMVector | Returns the cross product of V1 and V2. |
Dot(XMVector, XMVector)
Computes the dot product between 3D vectors.
Declaration
public static XMVector Dot(XMVector v1, XMVector v2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v1 | The first vector. |
XMVector | v2 | The second vector. |
Returns
Type | Description |
---|---|
XMVector | Returns a vector. The dot product between V1 and V2 is replicated into each component. |
Equal(XMVector, XMVector)
Tests whether two 3D vectors are equal.
Declaration
public static bool Equal(XMVector v1, XMVector v2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v1 | The first vector. |
XMVector | v2 | The second vector. |
Returns
Type | Description |
---|---|
bool | Returns true if the 3D vectors are equal and false otherwise. |
EqualInt(XMVector, XMVector)
Tests whether two 3D vectors are equal, treating each component as an unsigned integer.
Declaration
public static bool EqualInt(XMVector v1, XMVector v2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v1 | The first vector. |
XMVector | v2 | The second vector. |
Returns
Type | Description |
---|---|
bool | Returns true if the 3D vectors are equal and false otherwise. |
EqualIntR(XMVector, XMVector)
Tests whether two 3D vectors are equal, treating each component as an unsigned integer. In addition, this function returns a comparison value.
Declaration
public static XMComparisonRecord EqualIntR(XMVector v1, XMVector v2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v1 | The first vector. |
XMVector | v2 | The second vector. |
Returns
Type | Description |
---|---|
XMComparisonRecord | Returns a comparison value. |
EqualR(XMVector, XMVector)
Tests whether two 3D vectors are equal. In addition, this function returns a comparison value.
Declaration
public static XMComparisonRecord EqualR(XMVector v1, XMVector v2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v1 | The first vector. |
XMVector | v2 | The second vector. |
Returns
Type | Description |
---|---|
XMComparisonRecord | Returns a comparison value. |
Greater(XMVector, XMVector)
Tests whether one 3D vector is greater than another 3D vector.
Declaration
public static bool Greater(XMVector v1, XMVector v2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v1 | The first vector. |
XMVector | v2 | The second vector. |
Returns
Type | Description |
---|---|
bool | Returns true if V1 is greater than V2 and false otherwise. |
GreaterOrEqual(XMVector, XMVector)
Tests whether one 3D vector is greater-than-or-equal-to another 3D vector.
Declaration
public static bool GreaterOrEqual(XMVector v1, XMVector v2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v1 | The first vector. |
XMVector | v2 | The second vector. |
Returns
Type | Description |
---|---|
bool | Returns true if V1 is greater-than-or-equal-to V2 and false otherwise. |
GreaterOrEqualR(XMVector, XMVector)
Tests whether one 3D vector is greater-than-or-equal-to another 3D vector and returns a comparison value.
Declaration
public static XMComparisonRecord GreaterOrEqualR(XMVector v1, XMVector v2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v1 | The first vector. |
XMVector | v2 | The second vector. |
Returns
Type | Description |
---|---|
XMComparisonRecord | Returns a comparison value. |
GreaterR(XMVector, XMVector)
Tests whether one 3D vector is greater than another 3D vector and returns a comparison value.
Declaration
public static XMComparisonRecord GreaterR(XMVector v1, XMVector v2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v1 | The first vector. |
XMVector | v2 | The second vector. |
Returns
Type | Description |
---|---|
XMComparisonRecord | Returns a comparison value. |
InBounds(XMVector, XMVector)
Tests whether the components of a 3D vector are within set bounds.
Declaration
public static bool InBounds(XMVector v, XMVector bounds)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The vector to test. |
XMVector | bounds | The vector that determines the bounds. |
Returns
Type | Description |
---|---|
bool | Returns true if both the x, y, and z-components of V are within the set bounds, and false otherwise. |
InverseRotate(XMVector, XMVector)
Rotates a 3D vector using the inverse of a quaternion.
Declaration
public static XMVector InverseRotate(XMVector v, XMVector rotationQuaternion)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The vector to rotate. |
XMVector | rotationQuaternion | The quaternion that describes the inverse of the rotation to apply to the vector. |
Returns
Type | Description |
---|---|
XMVector | Returns the rotated 3D vector. |
IsInfinite(XMVector)
Tests whether any component of a 3D vector is positive or negative infinity.
Declaration
public static bool IsInfinite(XMVector v)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The vector. |
Returns
Type | Description |
---|---|
bool | Returns true if any component of V is positive or negative infinity, and false otherwise. |
IsNaN(XMVector)
Tests whether any component of a 3D vector is a NaN.
Declaration
public static bool IsNaN(XMVector v)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The vector. |
Returns
Type | Description |
---|---|
bool | Returns true if any component of V is a NaN, and false otherwise. |
Length(XMVector)
Computes the length of a 3D vector.
Declaration
public static XMVector Length(XMVector v)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The vector. |
Returns
Type | Description |
---|---|
XMVector | Returns a vector. The length of V is replicated into each component. |
LengthEst(XMVector)
Estimates the length of a 3D vector.
Declaration
public static XMVector LengthEst(XMVector v)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The vector. |
Returns
Type | Description |
---|---|
XMVector | Returns a vector, each of whose components are estimates of the length of V. |
LengthSquare(XMVector)
Computes the square of the length of a 3D vector.
Declaration
public static XMVector LengthSquare(XMVector v)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The vector. |
Returns
Type | Description |
---|---|
XMVector | Returns a vector. The square of the length of V is replicated into each component. |
Less(XMVector, XMVector)
Tests whether one 3D vector is less than another 3D vector.
Declaration
public static bool Less(XMVector v1, XMVector v2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v1 | The fist vector. |
XMVector | v2 | The second vector. |
Returns
Type | Description |
---|---|
bool | Returns true if V1 is less than V2 and false otherwise. |
LessOrEqual(XMVector, XMVector)
Tests whether one 3D vector is less-than-or-equal-to another 3D vector.
Declaration
public static bool LessOrEqual(XMVector v1, XMVector v2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v1 | The first vector. |
XMVector | v2 | The second vector. |
Returns
Type | Description |
---|---|
bool | Returns true if V1 is less-than-or-equal-to V2 and false otherwise. |
LinePointDistance(XMVector, XMVector, XMVector)
Computes the minimum distance between a line and a point.
Declaration
public static XMVector LinePointDistance(XMVector linePoint1, XMVector linePoint2, XMVector point)
Parameters
Type | Name | Description |
---|---|---|
XMVector | linePoint1 | The first point on the line. |
XMVector | linePoint2 | The second point on the line. |
XMVector | point | The reference point. |
Returns
Type | Description |
---|---|
XMVector | Returns a vector. The minimum distance between the line and the point is replicated to each of the components. |
NearEqual(XMVector, XMVector, XMVector)
Tests whether one 3D vector is near another 3D vector.
Declaration
public static bool NearEqual(XMVector v1, XMVector v2, XMVector epsilon)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v1 | The first vector. |
XMVector | v2 | The second vector. |
XMVector | epsilon | Tolerance value used for judging equality. |
Returns
Type | Description |
---|---|
bool | Returns true if V1 is near V2 and false otherwise. |
Normalize(XMVector)
Returns the normalized version of a 3D vector.
Declaration
public static XMVector Normalize(XMVector v)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The vector. |
Returns
Type | Description |
---|---|
XMVector | Returns the normalized version of V. |
NormalizeEst(XMVector)
Estimates the normalized version of a 3D vector.
Declaration
public static XMVector NormalizeEst(XMVector v)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The vector. |
Returns
Type | Description |
---|---|
XMVector | Returns an estimate of the normalized version of V. |
NotEqual(XMVector, XMVector)
Tests whether two 3D vectors are not equal.
Declaration
public static bool NotEqual(XMVector v1, XMVector v2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v1 | The first vector. |
XMVector | v2 | The second vector. |
Returns
Type | Description |
---|---|
bool | Returns true if the 3D vectors are not equal and false otherwise. |
NotEqualInt(XMVector, XMVector)
Test whether two 3D vectors are not equal, treating each component as an unsigned integer.
Declaration
public static bool NotEqualInt(XMVector v1, XMVector v2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v1 | The first vector. |
XMVector | v2 | The second vector. |
Returns
Type | Description |
---|---|
bool | Returns true if the 3D vectors are not equal and false otherwise. |
Orthogonal(XMVector)
Computes a vector perpendicular to a 3D vector.
Declaration
public static XMVector Orthogonal(XMVector v)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The vector. |
Returns
Type | Description |
---|---|
XMVector | Returns a 3D vector orthogonal to V. |
Project(XMVector, float, float, float, float, float, float, XMMatrix, XMMatrix, XMMatrix)
Project a 3D vector from object space into screen space.
Declaration
public static XMVector Project(XMVector v, float viewportX, float viewportY, float viewportWidth, float viewportHeight, float viewportMinZ, float viewportMaxZ, XMMatrix projection, XMMatrix view, XMMatrix world)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The vector in object space that will be projected into screen space. |
float | viewportX | Pixel coordinate of the upper-left corner of the viewport. Unless you want to render to a subset of the surface, this parameter can be set to 0. |
float | viewportY | Pixel coordinate of the upper-left corner of the viewport on the render-target surface. Unless you want to render to a subset of the surface, this parameter can be set to 0. |
float | viewportWidth | Width dimension of the clip volume, in pixels. Unless you are rendering only to a subset of the surface, this parameter should be set to the width dimension of the render-target surface. |
float | viewportHeight | Height dimension of the clip volume, in pixels. Unless you are rendering only to a subset of the surface, this parameter should be set to the height dimension of the render-target surface. |
float | viewportMinZ | Together with ViewportMaxZ, value describing the range of depth values into which a scene is to be rendered, the minimum and maximum values of the clip volume. Most applications set this value to 0.0f. Clipping is performed after applying the projection matrix. |
float | viewportMaxZ | Together with MinZ, value describing the range of depth values into which a scene is to be rendered, the minimum and maximum values of the clip volume. Most applications set this value to 1.0f. Clipping is performed after applying the projection matrix. |
XMMatrix | projection | Projection matrix. |
XMMatrix | view | View matrix. |
XMMatrix | world | World matrix. |
Returns
Type | Description |
---|---|
XMVector | Returns a vector in screen space. |
ReciprocalLength(XMVector)
Computes the reciprocal of the length of a 3D vector.
Declaration
public static XMVector ReciprocalLength(XMVector v)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The vector. |
Returns
Type | Description |
---|---|
XMVector | Returns a vector. The reciprocal of the length of V is replicated into each of the returned vector's components. |
ReciprocalLengthEst(XMVector)
Estimates the reciprocal of the length of a 3D vector.
Declaration
public static XMVector ReciprocalLengthEst(XMVector v)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The vector. |
Returns
Type | Description |
---|---|
XMVector | Returns a vector, each of whose components are estimates of the reciprocal of the length of V. |
Reflect(XMVector, XMVector)
Reflects an incident 3D vector across a 3D normal vector.
Declaration
public static XMVector Reflect(XMVector incident, XMVector normal)
Parameters
Type | Name | Description |
---|---|---|
XMVector | incident | The incident vector to reflect. |
XMVector | normal | The normal vector to reflect the incident vector across. |
Returns
Type | Description |
---|---|
XMVector | Returns the reflected incident angle. |
Refract(XMVector, XMVector, float)
Refracts an incident 3D vector across a 3D normal vector.
Declaration
public static XMVector Refract(XMVector incident, XMVector normal, float refractionIndex)
Parameters
Type | Name | Description |
---|---|---|
XMVector | incident | The incident vector to refract. |
XMVector | normal | The normal vector to refract the incident vector through. |
float | refractionIndex | The index of refraction. |
Returns
Type | Description |
---|---|
XMVector | Returns the refracted incident vector. |
RefractV(XMVector, XMVector, XMVector)
Refracts an incident 3D vector across a 3D normal vector.
Declaration
public static XMVector RefractV(XMVector incident, XMVector normal, XMVector refractionIndex)
Parameters
Type | Name | Description |
---|---|---|
XMVector | incident | The incident vector to refract. |
XMVector | normal | The normal vector to refract the incident vector through. |
XMVector | refractionIndex | A vector whose x, y, and z-components are equal to the index of refraction. |
Returns
Type | Description |
---|---|
XMVector | Returns the refracted incident vector. |
Rotate(XMVector, XMVector)
Rotates a 3D vector using a quaternion.
Declaration
public static XMVector Rotate(XMVector v, XMVector rotationQuaternion)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The vector to rotate. |
XMVector | rotationQuaternion | The quaternion that describes the rotation to apply to the vector. |
Returns
Type | Description |
---|---|
XMVector | The rotated 3D vector. |
Transform(XMVector, XMMatrix)
Transforms a 3D vector by a matrix.
Declaration
public static XMVector Transform(XMVector v, XMMatrix m)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The vector. |
XMMatrix | m | The transformation matrix. |
Returns
Type | Description |
---|---|
XMVector | Returns the transformed vector. |
TransformCoord(XMVector, XMMatrix)
Transforms a 3D vector by a given matrix, projecting the result back into w = 1.
Declaration
public static XMVector TransformCoord(XMVector v, XMMatrix m)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The vector. |
XMMatrix | m | The transformation matrix. |
Returns
Type | Description |
---|---|
XMVector | Returns the transformed vector. |
TransformNormal(XMVector, XMMatrix)
Transforms the 3D vector normal by the given matrix.
Declaration
public static XMVector TransformNormal(XMVector v, XMMatrix m)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The normal vector. |
XMMatrix | m | The transformation matrix. |
Returns
Type | Description |
---|---|
XMVector | Returns the transformed vector. |
Unproject(XMVector, float, float, float, float, float, float, XMMatrix, XMMatrix, XMMatrix)
Projects a 3D vector from screen space into object space.
Declaration
public static XMVector Unproject(XMVector v, float viewportX, float viewportY, float viewportWidth, float viewportHeight, float viewportMinZ, float viewportMaxZ, XMMatrix projection, XMMatrix view, XMMatrix world)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The vector in screen space that will be projected into object space. |
float | viewportX | Pixel coordinate of the upper-left corner of the viewport. Unless you want to render to a subset of the surface, this parameter can be set to 0. |
float | viewportY | Pixel coordinate of the upper-left corner of the viewport on the render-target surface. Unless you want to render to a subset of the surface, this parameter can be set to 0. |
float | viewportWidth | Width dimension of the clip volume, in pixels. Unless you are rendering only to a subset of the surface, this parameter should be set to the width dimension of the render-target surface. |
float | viewportHeight | Height dimension of the clip volume, in pixels. Unless you are rendering only to a subset of the surface, this parameter should be set to the height dimension of the render-target surface. |
float | viewportMinZ | Together with ViewportMaxZ, value describing the range of depth values into which a scene is to be rendered, the minimum and maximum values of the clip volume. Most applications set this value to 0.0f. Clipping is performed after applying the projection matrix. |
float | viewportMaxZ | Together with MinZ, value describing the range of depth values into which a scene is to be rendered, the minimum and maximum values of the clip volume. Most applications set this value to 1.0f. Clipping is performed after applying the projection matrix. |
XMMatrix | projection | Projection matrix. |
XMMatrix | view | View matrix. |
XMMatrix | world | World matrix. |
Returns
Type | Description |
---|---|
XMVector | Returns a vector in object space. |