Class Vector4Helper
- Namespace
- HelixToolkit.Maths
- Assembly
- HelixToolkit.Maths.dll
Represents a four dimensional mathematical vector.
public static class Vector4Helper
- Inheritance
-
Vector4Helper
- Inherited Members
Fields
One
A Vector4 with all of its components set to one.
public static readonly Vector4 One
Field Value
SizeInBytes
The size of the Vector4 type, in bytes.
public static readonly int SizeInBytes
Field Value
UnitW
The W unit Vector4 (0, 0, 0, 1).
public static readonly Vector4 UnitW
Field Value
UnitX
The X unit Vector4 (1, 0, 0, 0).
public static readonly Vector4 UnitX
Field Value
UnitY
The Y unit Vector4 (0, 1, 0, 0).
public static readonly Vector4 UnitY
Field Value
UnitZ
The Z unit Vector4 (0, 0, 1, 0).
public static readonly Vector4 UnitZ
Field Value
Zero
A Vector4 with all of its components set to zero.
public static readonly Vector4 Zero
Field Value
Methods
Barycentric(Vector4, Vector4, Vector4, float, float)
Returns a Vector4 containing the 4D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 4D triangle.
public static Vector4 Barycentric(Vector4 value1, Vector4 value2, Vector4 value3, float amount1, float amount2)
Parameters
value1Vector4A Vector4 containing the 4D Cartesian coordinates of vertex 1 of the triangle.
value2Vector4A Vector4 containing the 4D Cartesian coordinates of vertex 2 of the triangle.
value3Vector4A Vector4 containing the 4D Cartesian coordinates of vertex 3 of the triangle.
amount1floatBarycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in
value2).amount2floatBarycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in
value3).
Returns
Barycentric(ref Vector4, ref Vector4, ref Vector4, float, float, out Vector4)
Returns a Vector4 containing the 4D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 4D triangle.
public static void Barycentric(ref Vector4 value1, ref Vector4 value2, ref Vector4 value3, float amount1, float amount2, out Vector4 result)
Parameters
value1Vector4A Vector4 containing the 4D Cartesian coordinates of vertex 1 of the triangle.
value2Vector4A Vector4 containing the 4D Cartesian coordinates of vertex 2 of the triangle.
value3Vector4A Vector4 containing the 4D Cartesian coordinates of vertex 3 of the triangle.
amount1floatBarycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in
value2).amount2floatBarycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in
value3).resultVector4When the method completes, contains the 4D Cartesian coordinates of the specified point.
CatmullRom(Vector4, Vector4, Vector4, Vector4, float)
Performs a Catmull-Rom interpolation using the specified positions.
public static Vector4 CatmullRom(Vector4 value1, Vector4 value2, Vector4 value3, Vector4 value4, float amount)
Parameters
value1Vector4The first position in the interpolation.
value2Vector4The second position in the interpolation.
value3Vector4The third position in the interpolation.
value4Vector4The fourth position in the interpolation.
amountfloatWeighting factor.
Returns
- Vector4
A vector that is the result of the Catmull-Rom interpolation.
CatmullRom(ref Vector4, ref Vector4, ref Vector4, ref Vector4, float, out Vector4)
Performs a Catmull-Rom interpolation using the specified positions.
public static void CatmullRom(ref Vector4 value1, ref Vector4 value2, ref Vector4 value3, ref Vector4 value4, float amount, out Vector4 result)
Parameters
value1Vector4The first position in the interpolation.
value2Vector4The second position in the interpolation.
value3Vector4The third position in the interpolation.
value4Vector4The fourth position in the interpolation.
amountfloatWeighting factor.
resultVector4When the method completes, contains the result of the Catmull-Rom interpolation.
Clamp(Vector4, Vector4, Vector4)
public static Vector4 Clamp(this Vector4 value, Vector4 min, Vector4 max)
Parameters
Returns
Clamp(ref Vector4, ref Vector4, ref Vector4, out Vector4)
public static void Clamp(ref Vector4 value, ref Vector4 min, ref Vector4 max, out Vector4 result)
Parameters
Get(Vector4, int)
Gets or sets the component at the specified index.
public static float Get(this Vector4 v, int index)
Parameters
vVector4indexintThe index of the component to access. Use 0 for the X component, 1 for the Y component, 2 for the Z component, and 3 for the W component.
Returns
- float
The value of the X, Y, Z, or W component, depending on the index.
Exceptions
- ArgumentOutOfRangeException
Thrown when the
indexis out of the range [0, 3].
Hermite(Vector4, Vector4, Vector4, Vector4, float)
Performs a Hermite spline interpolation.
public static Vector4 Hermite(Vector4 value1, Vector4 tangent1, Vector4 value2, Vector4 tangent2, float amount)
Parameters
value1Vector4First source position vector.
tangent1Vector4First source tangent vector.
value2Vector4Second source position vector.
tangent2Vector4Second source tangent vector.
amountfloatWeighting factor.
Returns
- Vector4
The result of the Hermite spline interpolation.
Hermite(ref Vector4, ref Vector4, ref Vector4, ref Vector4, float, out Vector4)
Performs a Hermite spline interpolation.
public static void Hermite(ref Vector4 value1, ref Vector4 tangent1, ref Vector4 value2, ref Vector4 tangent2, float amount, out Vector4 result)
Parameters
value1Vector4First source position vector.
tangent1Vector4First source tangent vector.
value2Vector4Second source position vector.
tangent2Vector4Second source tangent vector.
amountfloatWeighting factor.
resultVector4When the method completes, contains the result of the Hermite spline interpolation.
IsNormalized(Vector4)
Gets a value indicting whether this instance is normalized.
public static bool IsNormalized(this Vector4 v)
Parameters
vVector4
Returns
IsZero(Vector4)
Gets a value indicting whether this vector is zero
public static bool IsZero(this Vector4 v)
Parameters
vVector4
Returns
Max(Vector4, Vector4)
public static Vector4 Max(this Vector4 v1, Vector4 v2)
Parameters
Returns
Max(Vector4, ref Vector4)
public static Vector4 Max(this Vector4 v1, ref Vector4 v2)
Parameters
Returns
Min(Vector4, Vector4)
public static Vector4 Min(this Vector4 v1, Vector4 v2)
Parameters
Returns
Min(Vector4, ref Vector4)
public static Vector4 Min(this Vector4 v1, ref Vector4 v2)
Parameters
Returns
Orthogonalize(Vector4[], params Vector4[])
Orthogonalizes a list of vectors.
public static void Orthogonalize(Vector4[] destination, params Vector4[] source)
Parameters
destinationVector4[]The list of orthogonalized vectors.
sourceVector4[]The list of vectors to orthogonalize.
Remarks
Orthogonalization is the process of making all vectors orthogonal to each other. This means that any given vector in the list will be orthogonal to any other given vector in the list.
Because this method uses the modified Gram-Schmidt process, the resulting vectors tend to be numerically unstable. The numeric stability decreases according to the vectors position in the list so that the first vector is the most stable and the last vector is the least stable.
Exceptions
- ArgumentNullException
Thrown when
sourceordestinationisnull.- ArgumentOutOfRangeException
Thrown when
destinationis shorter in length thansource.
Orthonormalize(Vector4[], params Vector4[])
Orthonormalizes a list of vectors.
public static void Orthonormalize(Vector4[] destination, params Vector4[] source)
Parameters
destinationVector4[]The list of orthonormalized vectors.
sourceVector4[]The list of vectors to orthonormalize.
Remarks
Orthonormalization is the process of making all vectors orthogonal to each other and making all vectors of unit length. This means that any given vector will be orthogonal to any other given vector in the list.
Because this method uses the modified Gram-Schmidt process, the resulting vectors tend to be numerically unstable. The numeric stability decreases according to the vectors position in the list so that the first vector is the most stable and the last vector is the least stable.
Exceptions
- ArgumentNullException
Thrown when
sourceordestinationisnull.- ArgumentOutOfRangeException
Thrown when
destinationis shorter in length thansource.
Set(ref Vector4, int, float)
public static void Set(ref Vector4 v, int index, float value)
Parameters
SmoothStep(Vector4, Vector4, float)
Performs a cubic interpolation between two vectors.
public static Vector4 SmoothStep(Vector4 start, Vector4 end, float amount)
Parameters
startVector4Start vector.
endVector4End vector.
amountfloatValue between 0 and 1 indicating the weight of
end.
Returns
- Vector4
The cubic interpolation of the two vectors.
SmoothStep(ref Vector4, ref Vector4, float, out Vector4)
Performs a cubic interpolation between two vectors.
public static void SmoothStep(ref Vector4 start, ref Vector4 end, float amount, out Vector4 result)
Parameters
startVector4Start vector.
endVector4End vector.
amountfloatValue between 0 and 1 indicating the weight of
end.resultVector4When the method completes, contains the cubic interpolation of the two vectors.
ToArray(Vector4)
Creates an array containing the elements of the vector.
public static float[] ToArray(this Vector4 v)
Parameters
vVector4
Returns
- float[]
A four-element array containing the components of the vector.
Transform(Vector4, ref Matrix4x4)
Transforms a 4D vector by the given Matrix4x4.
public static Vector4 Transform(this Vector4 vector, ref Matrix4x4 transform)
Parameters
Returns
Transform(ref Vector4, ref Matrix4x4, out Vector4)
Transforms a 4D vector by the given Matrix4x4.
public static void Transform(ref Vector4 vector, ref Matrix4x4 transform, out Vector4 result)
Parameters
vectorVector4The source vector.
transformMatrix4x4The transformation Matrix4x4.
resultVector4When the method completes, contains the transformed Vector4.
Transform(Vector4[], ref Matrix4x4, Vector4[])
Transforms an array of 4D vectors by the given Matrix4x4.
public static void Transform(this Vector4[] source, ref Matrix4x4 transform, Vector4[] destination)
Parameters
sourceVector4[]The array of vectors to transform.
transformMatrix4x4The transformation Matrix4x4.
destinationVector4[]The array for which the transformed vectors are stored. This array may be the same array as
source.
Exceptions
- ArgumentNullException
Thrown when
sourceordestinationisnull.- ArgumentOutOfRangeException
Thrown when
destinationis shorter in length thansource.
Transform(Vector4[], ref Quaternion, Vector4[])
Transforms an array of vectors by the given Quaternion rotation.
public static void Transform(Vector4[] source, ref Quaternion rotation, Vector4[] destination)
Parameters
sourceVector4[]The array of vectors to transform.
rotationQuaternionThe Quaternion rotation to apply.
destinationVector4[]The array for which the transformed vectors are stored. This array may be the same array as
source.
Exceptions
- ArgumentNullException
Thrown when
sourceordestinationisnull.- ArgumentOutOfRangeException
Thrown when
destinationis shorter in length thansource.