Class XMVector2
The 2D vector functions provided by DirectXMath.
Inherited Members
Namespace: JeremyAnsel.DirectX.DXMath
Assembly: JeremyAnsel.DirectX.DXMath.dll
Syntax
public static class XMVector2
Methods
| Edit this page View SourceAngleBetweenNormals(XMVector, XMVector)
Computes the radian angle between two normalized 2D vectors.
Declaration
public static XMVector AngleBetweenNormals(XMVector n1, XMVector n2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | n1 | The first vector. |
XMVector | n2 | The second 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 2D vectors.
Declaration
public static XMVector AngleBetweenNormalsEst(XMVector n1, XMVector n2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | n1 | The first vector. |
XMVector | n2 | The second 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 2D 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 2D vector to a given range.
Declaration
public static XMVector ClampLength(XMVector v, float lengthMin, float lengthMax)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The 2D vector. |
float | lengthMin | Minimum clamp length. |
float | lengthMax | Maximum clamp length. |
Returns
Type | Description |
---|---|
XMVector | Returns a 2D vector whose length is clamped to the specified minimum and maximum. |
ClampLengthV(XMVector, XMVector, XMVector)
Clamps the length of a 2D vector to a given range.
Declaration
public static XMVector ClampLengthV(XMVector v, XMVector lengthMin, XMVector lengthMax)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The 2D vector to clamp. |
XMVector | lengthMin | The 2D vector whose x and y-components are both equal to the minimum clamp length. The x and y-components must be greater-than-or-equal to zero. |
XMVector | lengthMax | The 2D vector whose x and y-components are both equal to the maximum clamp length. The x and y-components must be greater-than-or-equal to zero. |
Returns
Type | Description |
---|---|
XMVector | Returns a 2D vector whose length is clamped to the specified minimum and maximum. |
Cross(XMVector, XMVector)
Computes the 2D cross product.
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 a vector. The 2D cross product is replicated into each component. |
Dot(XMVector, XMVector)
Computes the dot product between 2D 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 2D 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 2D vectors are equal and false otherwise. |
EqualInt(XMVector, XMVector)
Tests whether two 2D 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 2D vectors are equal and false otherwise. |
EqualIntR(XMVector, XMVector)
Tests whether two 2D vectors are equal, treating each component as an unsigned integer. In addition, this function returns a comparison.
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 2D 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 2D vector is greater than another 2D 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. See the remarks section. |
GreaterOrEqual(XMVector, XMVector)
Tests whether one 2D vector is greater-than-or-equal-to another 2D 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 2D vector is greater-than-or-equal-to another 2D 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 2D vector is greater than another 2D 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 2D vector are within set bounds.
Declaration
public static bool InBounds(XMVector v, XMVector bounds)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The 2D vector to test. |
XMVector | bounds | The 2D vector that determines the bounds. |
Returns
Type | Description |
---|---|
bool | Returns true if both the x and y-components of V are within the set bounds, and false otherwise. |
IntersectLine(XMVector, XMVector, XMVector, XMVector)
Finds the intersection of two lines.
Declaration
public static XMVector IntersectLine(XMVector line1Point1, XMVector line1Point2, XMVector line2Point1, XMVector line2Point2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | line1Point1 | 2D vector describing the first point on the first line. |
XMVector | line1Point2 | 2D vector describing a second point on the first line. |
XMVector | line2Point1 | 2D vector describing the first point on the second line. |
XMVector | line2Point2 | 2D vector describing a second point on the second line. |
Returns
Type | Description |
---|---|
XMVector | Returns the intersection point. If the lines are parallel, the returned vector will be a NaN. If the two lines are coincident, the returned vector will be positive infinity. |
IsInfinite(XMVector)
Tests whether any component of a 2D 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 2D 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 2D vector.
Declaration
public static XMVector Length(XMVector v)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The 2D vector. |
Returns
Type | Description |
---|---|
XMVector | Returns a vector. The length of V is replicated into each component. |
LengthEst(XMVector)
Estimates the length of a 2D vector.
Declaration
public static XMVector LengthEst(XMVector v)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The 2D 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 2D vector.
Declaration
public static XMVector LengthSquare(XMVector v)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The 2D 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 2D vector is less than another 2D vector.
Declaration
public static bool Less(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 V2 and false otherwise. |
LessOrEqual(XMVector, XMVector)
Tests whether one 2D vector is less-than-or-equal-to another 2D 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 | 2D vector describing a first point on the line. |
XMVector | linePoint2 | 2D vector describing a second point on the line. |
XMVector | point | 2D vector describing 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 2D vector is near another 2D 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 | The tolerance value used for judging equality. |
Returns
Type | Description |
---|---|
bool | Returns true if the difference between components is less than Epsilon; returns false otherwise. |
Normalize(XMVector)
Returns the normalized version of a 2D vector.
Declaration
public static XMVector Normalize(XMVector v)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The 2D vector. |
Returns
Type | Description |
---|---|
XMVector | Returns the normalized version of V. |
NormalizeEst(XMVector)
Estimates the normalized version of a 2D vector.
Declaration
public static XMVector NormalizeEst(XMVector v)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The 2D vector. |
Returns
Type | Description |
---|---|
XMVector | Returns an estimate of the normalized version of V. |
NotEqual(XMVector, XMVector)
Tests whether two 2D 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 2D vectors are not equal and false otherwise. |
NotEqualInt(XMVector, XMVector)
Test whether two 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 2D vectors are not equal and false otherwise. |
Orthogonal(XMVector)
Computes a vector perpendicular to a 2D vector.
Declaration
public static XMVector Orthogonal(XMVector v)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The 2D vector. |
Returns
Type | Description |
---|---|
XMVector | Returns the 2D vector orthogonal to V. |
ReciprocalLength(XMVector)
Computes the reciprocal of the length of a 2D vector.
Declaration
public static XMVector ReciprocalLength(XMVector v)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The 2D vector. |
Returns
Type | Description |
---|---|
XMVector | Returns the reciprocal of the length of V. |
ReciprocalLengthEst(XMVector)
Estimates the reciprocal of the length of a 2D vector.
Declaration
public static XMVector ReciprocalLengthEst(XMVector v)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The 2D 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 2D vector across a 2D normal vector.
Declaration
public static XMVector Reflect(XMVector incident, XMVector normal)
Parameters
Type | Name | Description |
---|---|---|
XMVector | incident | The 2D incident vector to reflect. |
XMVector | normal | The 2D normal vector to reflect the incident vector across. |
Returns
Type | Description |
---|---|
XMVector | Returns the reflected incident angle. |
Refract(XMVector, XMVector, float)
Refracts an incident 2D vector across a 2D normal vector.
Declaration
public static XMVector Refract(XMVector incident, XMVector normal, float refractionIndex)
Parameters
Type | Name | Description |
---|---|---|
XMVector | incident | The 2D incident vector to refract. |
XMVector | normal | The 2D 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 2D vector across a 2D normal vector.
Declaration
public static XMVector RefractV(XMVector incident, XMVector normal, XMVector refractionIndex)
Parameters
Type | Name | Description |
---|---|---|
XMVector | incident | The 2D incident vector to refract. |
XMVector | normal | The 2D normal vector to refract the incident vector through. |
XMVector | refractionIndex | The 2D vector whose x and y-components are both equal to the index of refraction. |
Returns
Type | Description |
---|---|
XMVector | Returns the refracted incident vector. |
Transform(XMVector, XMMatrix)
Transforms a 2D vector by a matrix.
Declaration
public static XMVector Transform(XMVector v, XMMatrix m)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The 2D vector. |
XMMatrix | m | The transformation matrix. |
Returns
Type | Description |
---|---|
XMVector | Returns the transformed vector. |
TransformCoord(XMVector, XMMatrix)
Transforms a 2D 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 2D vector. |
XMMatrix | m | The transformation matrix. |
Returns
Type | Description |
---|---|
XMVector | Returns the transformed vector. |
TransformNormal(XMVector, XMMatrix)
Transforms the 2D vector normal by the given matrix.
Declaration
public static XMVector TransformNormal(XMVector v, XMMatrix m)
Parameters
Type | Name | Description |
---|---|---|
XMVector | v | The 2D normal vector. |
XMMatrix | m | The transformation matrix. |
Returns
Type | Description |
---|---|
XMVector | Returns the transformed vector. |