Table of Contents

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

Vector4

SizeInBytes

The size of the Vector4 type, in bytes.

public static readonly int SizeInBytes

Field Value

int

UnitW

The W unit Vector4 (0, 0, 0, 1).

public static readonly Vector4 UnitW

Field Value

Vector4

UnitX

The X unit Vector4 (1, 0, 0, 0).

public static readonly Vector4 UnitX

Field Value

Vector4

UnitY

The Y unit Vector4 (0, 1, 0, 0).

public static readonly Vector4 UnitY

Field Value

Vector4

UnitZ

The Z unit Vector4 (0, 0, 1, 0).

public static readonly Vector4 UnitZ

Field Value

Vector4

Zero

A Vector4 with all of its components set to zero.

public static readonly Vector4 Zero

Field Value

Vector4

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

value1 Vector4

A Vector4 containing the 4D Cartesian coordinates of vertex 1 of the triangle.

value2 Vector4

A Vector4 containing the 4D Cartesian coordinates of vertex 2 of the triangle.

value3 Vector4

A Vector4 containing the 4D Cartesian coordinates of vertex 3 of the triangle.

amount1 float

Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in value2).

amount2 float

Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in value3).

Returns

Vector4

A new Vector4 containing the 4D Cartesian coordinates of the specified point.

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

value1 Vector4

A Vector4 containing the 4D Cartesian coordinates of vertex 1 of the triangle.

value2 Vector4

A Vector4 containing the 4D Cartesian coordinates of vertex 2 of the triangle.

value3 Vector4

A Vector4 containing the 4D Cartesian coordinates of vertex 3 of the triangle.

amount1 float

Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in value2).

amount2 float

Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in value3).

result Vector4

When 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

value1 Vector4

The first position in the interpolation.

value2 Vector4

The second position in the interpolation.

value3 Vector4

The third position in the interpolation.

value4 Vector4

The fourth position in the interpolation.

amount float

Weighting 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

value1 Vector4

The first position in the interpolation.

value2 Vector4

The second position in the interpolation.

value3 Vector4

The third position in the interpolation.

value4 Vector4

The fourth position in the interpolation.

amount float

Weighting factor.

result Vector4

When 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

value Vector4
min Vector4
max Vector4

Returns

Vector4

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

value Vector4
min Vector4
max Vector4
result Vector4

Get(Vector4, int)

Gets or sets the component at the specified index.

public static float Get(this Vector4 v, int index)

Parameters

v Vector4
index int

The 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 index is 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

value1 Vector4

First source position vector.

tangent1 Vector4

First source tangent vector.

value2 Vector4

Second source position vector.

tangent2 Vector4

Second source tangent vector.

amount float

Weighting 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

value1 Vector4

First source position vector.

tangent1 Vector4

First source tangent vector.

value2 Vector4

Second source position vector.

tangent2 Vector4

Second source tangent vector.

amount float

Weighting factor.

result Vector4

When 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

v Vector4

Returns

bool

IsZero(Vector4)

Gets a value indicting whether this vector is zero

public static bool IsZero(this Vector4 v)

Parameters

v Vector4

Returns

bool

Max(Vector4, Vector4)

public static Vector4 Max(this Vector4 v1, Vector4 v2)

Parameters

v1 Vector4
v2 Vector4

Returns

Vector4

Max(Vector4, ref Vector4)

public static Vector4 Max(this Vector4 v1, ref Vector4 v2)

Parameters

v1 Vector4
v2 Vector4

Returns

Vector4

Min(Vector4, Vector4)

public static Vector4 Min(this Vector4 v1, Vector4 v2)

Parameters

v1 Vector4
v2 Vector4

Returns

Vector4

Min(Vector4, ref Vector4)

public static Vector4 Min(this Vector4 v1, ref Vector4 v2)

Parameters

v1 Vector4
v2 Vector4

Returns

Vector4

Orthogonalize(Vector4[], params Vector4[])

Orthogonalizes a list of vectors.

public static void Orthogonalize(Vector4[] destination, params Vector4[] source)

Parameters

destination Vector4[]

The list of orthogonalized vectors.

source Vector4[]

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 source or destination is null.

ArgumentOutOfRangeException

Thrown when destination is shorter in length than source.

Orthonormalize(Vector4[], params Vector4[])

Orthonormalizes a list of vectors.

public static void Orthonormalize(Vector4[] destination, params Vector4[] source)

Parameters

destination Vector4[]

The list of orthonormalized vectors.

source Vector4[]

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 source or destination is null.

ArgumentOutOfRangeException

Thrown when destination is shorter in length than source.

Set(ref Vector4, int, float)

public static void Set(ref Vector4 v, int index, float value)

Parameters

v Vector4
index int
value float

SmoothStep(Vector4, Vector4, float)

Performs a cubic interpolation between two vectors.

public static Vector4 SmoothStep(Vector4 start, Vector4 end, float amount)

Parameters

start Vector4

Start vector.

end Vector4

End vector.

amount float

Value 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

start Vector4

Start vector.

end Vector4

End vector.

amount float

Value between 0 and 1 indicating the weight of end.

result Vector4

When 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

v Vector4

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

vector Vector4

The source vector.

transform Matrix4x4

The transformation Matrix4x4.

Returns

Vector4

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

vector Vector4

The source vector.

transform Matrix4x4

The transformation Matrix4x4.

result Vector4

When 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

source Vector4[]

The array of vectors to transform.

transform Matrix4x4

The transformation Matrix4x4.

destination Vector4[]

The array for which the transformed vectors are stored. This array may be the same array as source.

Exceptions

ArgumentNullException

Thrown when source or destination is null.

ArgumentOutOfRangeException

Thrown when destination is shorter in length than source.

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

source Vector4[]

The array of vectors to transform.

rotation Quaternion

The Quaternion rotation to apply.

destination Vector4[]

The array for which the transformed vectors are stored. This array may be the same array as source.

Exceptions

ArgumentNullException

Thrown when source or destination is null.

ArgumentOutOfRangeException

Thrown when destination is shorter in length than source.