Table of Contents

Struct JVector

Namespace
Jitter2.LinearMath
Assembly
Jitter2.dll

Represents a three-dimensional vector with components of type float.

public struct JVector : IEquatable<JVector>
Implements
Inherited Members

Constructors

JVector(float)

Creates a vector with all components set to the same value.

public JVector(float xyz)

Parameters

xyz float

The value for X, Y, and Z components.

JVector(float, float, float)

Represents a three-dimensional vector with components of type float.

public JVector(float x, float y, float z)

Parameters

x float
y float
z float

Fields

MaxValue

A vector with all components set to MaxValue.

public static readonly JVector MaxValue

Field Value

JVector

MinValue

A vector with all components set to MinValue.

public static readonly JVector MinValue

Field Value

JVector

One

A vector with all components set to one (1, 1, 1).

public static readonly JVector One

Field Value

JVector

UnitX

The unit vector along the X-axis (1, 0, 0).

public static readonly JVector UnitX

Field Value

JVector

UnitY

The unit vector along the Y-axis (0, 1, 0).

public static readonly JVector UnitY

Field Value

JVector

UnitZ

The unit vector along the Z-axis (0, 0, 1).

public static readonly JVector UnitZ

Field Value

JVector

X

public float X

Field Value

float

Y

public float Y

Field Value

float

Z

public float Z

Field Value

float

Zero

The zero vector (0, 0, 0).

public static readonly JVector Zero

Field Value

JVector

Properties

this[int]

public float this[int i] { get; set; }

Parameters

i int

Property Value

float

Methods

Abs(in JVector)

Returns a vector containing the absolute values of the components of the specified vector.

public static JVector Abs(in JVector value1)

Parameters

value1 JVector

The input vector.

Returns

JVector

A vector with absolute values of each component.

Add(in JVector, in JVector)

Adds two vectors.

public static JVector Add(in JVector value1, in JVector value2)

Parameters

value1 JVector

The first vector.

value2 JVector

The second vector.

Returns

JVector

The sum of the two vectors.

Add(in JVector, in JVector, out JVector)

Adds two vectors.

public static void Add(in JVector value1, in JVector value2, out JVector result)

Parameters

value1 JVector

The first vector.

value2 JVector

The second vector.

result JVector

Output: The sum of the two vectors.

ConjugatedTransform(in JVector, in JQuaternion)

Transforms the vector by the conjugate of a quaternion (inverse rotation for unit quaternions).

public static JVector ConjugatedTransform(in JVector vector, in JQuaternion quat)

Parameters

vector JVector

The vector to transform.

quat JQuaternion

The quaternion (conjugated during operation).

Returns

JVector

The inversely rotated vector.

ConjugatedTransform(in JVector, in JQuaternion, out JVector)

Transforms the vector by the conjugate of a quaternion (inverse rotation).

public static void ConjugatedTransform(in JVector vector, in JQuaternion quaternion, out JVector result)

Parameters

vector JVector

The vector to transform.

quaternion JQuaternion

The quaternion (conjugated during operation).

result JVector

Output: The inversely rotated vector.

Cross(in JVector, in JVector)

Calculates the cross product of two vectors (u × v).

public static JVector Cross(in JVector vector1, in JVector vector2)

Parameters

vector1 JVector

The first vector.

vector2 JVector

The second vector.

Returns

JVector

The cross product.

Cross(in JVector, in JVector, out JVector)

Calculates the cross product of two vectors (u × v).

public static void Cross(in JVector vector1, in JVector vector2, out JVector result)

Parameters

vector1 JVector

The first vector.

vector2 JVector

The second vector.

result JVector

Output: The cross product.

Dot(in JVector, in JVector)

Calculates the dot product of two vectors (u · v).

public static float Dot(in JVector vector1, in JVector vector2)

Parameters

vector1 JVector

The first vector.

vector2 JVector

The second vector.

Returns

float

The dot product.

Equals(JVector)

Indicates whether the current object is equal to another object of the same type.

public readonly bool Equals(JVector other)

Parameters

other JVector

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object?)

Indicates whether this instance and a specified object are equal.

public override readonly bool Equals(object? obj)

Parameters

obj object

The object to compare with the current instance.

Returns

bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

GetHashCode()

Returns the hash code for this instance.

public override readonly int GetHashCode()

Returns

int

A 32-bit signed integer that is the hash code for this instance.

Length()

Calculates the length of the vector (‖v‖).

public readonly float Length()

Returns

float

LengthSquared()

Calculates the squared length of the vector (‖v‖²).

public readonly float LengthSquared()

Returns

float

Max(in JVector, in JVector)

Returns a vector containing the maximum components of the specified vectors.

public static JVector Max(in JVector value1, in JVector value2)

Parameters

value1 JVector

The first vector.

value2 JVector

The second vector.

Returns

JVector

A vector with the maximum of each component.

Max(in JVector, in JVector, out JVector)

Returns a vector containing the maximum components of the specified vectors.

public static void Max(in JVector value1, in JVector value2, out JVector result)

Parameters

value1 JVector

The first vector.

value2 JVector

The second vector.

result JVector

Output: A vector with the maximum of each component.

MaxAbs(in JVector)

Returns the maximum absolute value among the vector's components.

public static float MaxAbs(in JVector value1)

Parameters

value1 JVector

The input vector.

Returns

float

The maximum of |X|, |Y|, and |Z|.

Min(in JVector, in JVector)

Returns a vector containing the minimum components of the specified vectors.

public static JVector Min(in JVector value1, in JVector value2)

Parameters

value1 JVector

The first vector.

value2 JVector

The second vector.

Returns

JVector

A vector with the minimum of each component.

Min(in JVector, in JVector, out JVector)

Returns a vector containing the minimum components of the specified vectors.

public static void Min(in JVector value1, in JVector value2, out JVector result)

Parameters

value1 JVector

The first vector.

value2 JVector

The second vector.

result JVector

Output: A vector with the minimum of each component.

Multiply(in JVector, float)

Multiplies a vector by a scalar.

public static JVector Multiply(in JVector value1, float scaleFactor)

Parameters

value1 JVector

The vector.

scaleFactor float

The scalar factor.

Returns

JVector

The scaled vector.

Multiply(in JVector, float, out JVector)

Multiplies a vector by a scalar.

public static void Multiply(in JVector value1, float scaleFactor, out JVector result)

Parameters

value1 JVector

The vector.

scaleFactor float

The scalar factor.

result JVector

Output: The scaled vector.

Negate()

[Obsolete("Use static NegateInPlace instead.")]
public void Negate()

Negate(in JVector)

Returns a negated copy of the vector.

public static JVector Negate(in JVector value)

Parameters

value JVector

The vector to negate.

Returns

JVector

The negated vector.

Negate(in JVector, out JVector)

Returns a negated copy of the vector.

public static void Negate(in JVector value, out JVector result)

Parameters

value JVector

The vector to negate.

result JVector

Output: The negated vector.

NegateInPlace(ref JVector)

Negates the vector in-place.

public static void NegateInPlace(ref JVector vector)

Parameters

vector JVector

The vector to negate.

Normalize()

[Obsolete("In-place Normalize() is deprecated; use the static Normalize method or NormalizeInPlace.")]
public void Normalize()

Normalize(in JVector)

Returns a normalized unit vector.

public static JVector Normalize(in JVector value)

Parameters

value JVector

The vector to normalize.

Returns

JVector

The normalized unit vector.

Normalize(in JVector, out JVector)

Returns a normalized unit vector.

public static void Normalize(in JVector value, out JVector result)

Parameters

value JVector

The vector to normalize.

result JVector

Output: The normalized unit vector.

NormalizeInPlace(ref JVector)

Normalizes the vector in-place.

public static void NormalizeInPlace(ref JVector toNormalize)

Parameters

toNormalize JVector

The vector to normalize.

NormalizeSafe(in JVector, float)

Normalizes value; returns Zero when its squared-length is below epsilonSquared.

public static JVector NormalizeSafe(in JVector value, float epsilonSquared = 1E-16)

Parameters

value JVector

Vector to normalize.

epsilonSquared float

Cut-off for ‖value‖²; default is 1 × 10⁻¹⁶.

Returns

JVector

Unit vector or zero.

Outer(in JVector, in JVector)

Calculates the outer product (tensor product) of two vectors.

public static JMatrix Outer(in JVector u, in JVector v)

Parameters

u JVector

The first vector.

v JVector

The second vector.

Returns

JMatrix

A 3x3 matrix representing the outer product.

Remarks

Result is the matrix u * vᵀ.

Set(float, float, float)

[Obsolete("Do not use any longer.")]
public void Set(float x, float y, float z)

Parameters

x float
y float
z float

Subtract(JVector, JVector)

Subtracts the second vector from the first.

public static JVector Subtract(JVector value1, JVector value2)

Parameters

value1 JVector

The first vector.

value2 JVector

The second vector.

Returns

JVector

The difference of the two vectors.

Subtract(in JVector, in JVector, out JVector)

Subtracts the second vector from the first.

public static void Subtract(in JVector value1, in JVector value2, out JVector result)

Parameters

value1 JVector

The first vector.

value2 JVector

The second vector.

result JVector

Output: The difference of the two vectors.

Swap(ref JVector, ref JVector)

Swaps the values of two vectors.

public static void Swap(ref JVector vector1, ref JVector vector2)

Parameters

vector1 JVector
vector2 JVector

ToString()

Returns a string representation of the JVector.

public override readonly string ToString()

Returns

string

Transform(in JVector, in JMatrix)

Calculates matrix * vector (multiplying matrix by column vector).

public static JVector Transform(in JVector vector, in JMatrix matrix)

Parameters

vector JVector

The column vector.

matrix JMatrix

The matrix.

Returns

JVector

The transformed vector.

Transform(in JVector, in JMatrix, out JVector)

Calculates matrix * vector (multiplying matrix by column vector).

public static void Transform(in JVector vector, in JMatrix matrix, out JVector result)

Parameters

vector JVector

The column vector.

matrix JMatrix

The matrix.

result JVector

Output: The transformed vector.

Transform(in JVector, in JQuaternion)

Transforms the vector by a quaternion rotation.

public static JVector Transform(in JVector vector, in JQuaternion quat)

Parameters

vector JVector

The vector to transform.

quat JQuaternion

The quaternion representing the rotation.

Returns

JVector

The rotated vector.

Transform(in JVector, in JQuaternion, out JVector)

Transforms the vector by a quaternion rotation.

public static void Transform(in JVector vector, in JQuaternion quaternion, out JVector result)

Parameters

vector JVector

The vector to transform.

quaternion JQuaternion

The quaternion representing the rotation.

result JVector

Output: The rotated vector.

TransposedTransform(in JVector, in JMatrix)

Calculates matrixᵀ * vector (multiplying transposed matrix by column vector).

public static JVector TransposedTransform(in JVector vector, in JMatrix matrix)

Parameters

vector JVector

The column vector.

matrix JMatrix

The matrix (transposed during operation).

Returns

JVector

The transformed vector.

TransposedTransform(in JVector, in JMatrix, out JVector)

Calculates matrixᵀ * vector (multiplying transposed matrix by column vector).

public static void TransposedTransform(in JVector vector, in JMatrix matrix, out JVector result)

Parameters

vector JVector

The column vector.

matrix JMatrix

The matrix (transposed during operation).

result JVector

Output: The transformed vector.

UnsafeAs<T>()

Reinterprets the bits of this JVector as T.

public T UnsafeAs<T>() where T : unmanaged

Returns

T

The reinterpreted value.

Type Parameters

T

The target unmanaged type.

Remarks

Valid only if T has identical size and compatible layout.

UnsafeFrom<T>(in T)

Reinterprets the bits of value as a JVector.

public static JVector UnsafeFrom<T>(in T value) where T : unmanaged

Parameters

value T

The value to reinterpret.

Returns

JVector

The reinterpreted vector.

Type Parameters

T

The source unmanaged type.

Remarks

Valid only if T has identical size and compatible layout.

UnsafeGet(int)

public ref float UnsafeGet(int index)

Parameters

index int

Returns

float

Operators

operator +(in JVector, in JVector)

Adds two vectors.

public static JVector operator +(in JVector value1, in JVector value2)

Parameters

value1 JVector
value2 JVector

Returns

JVector

operator ==(JVector, JVector)

public static bool operator ==(JVector value1, JVector value2)

Parameters

value1 JVector
value2 JVector

Returns

bool

implicit operator Vector3(in JVector)

public static implicit operator Vector3(in JVector v)

Parameters

v JVector

Returns

Vector3

implicit operator JVector(in Vector3)

public static implicit operator JVector(in Vector3 v)

Parameters

v Vector3

Returns

JVector

implicit operator JVector((float x, float y, float z))

public static implicit operator JVector((float x, float y, float z) tuple)

Parameters

tuple (float x, float y, float z)

Returns

JVector

operator !=(JVector, JVector)

public static bool operator !=(JVector value1, JVector value2)

Parameters

value1 JVector
value2 JVector

Returns

bool

operator %(in JVector, in JVector)

Calculates the cross product of two vectors (u × v).

public static JVector operator %(in JVector vector1, in JVector vector2)

Parameters

vector1 JVector
vector2 JVector

Returns

JVector

operator *(in JVector, in JVector)

Calculates the dot product of two vectors (u · v).

public static float operator *(in JVector vector1, in JVector vector2)

Parameters

vector1 JVector
vector2 JVector

Returns

float

operator *(in JVector, float)

Multiplies a vector by a scalar.

public static JVector operator *(in JVector value1, float value2)

Parameters

value1 JVector
value2 float

Returns

JVector

operator *(float, in JVector)

Multiplies a vector by a scalar.

public static JVector operator *(float value1, in JVector value2)

Parameters

value1 float
value2 JVector

Returns

JVector

operator -(in JVector, in JVector)

Subtracts the second vector from the first.

public static JVector operator -(in JVector value1, in JVector value2)

Parameters

value1 JVector
value2 JVector

Returns

JVector

operator -(in JVector)

Negates the vector.

public static JVector operator -(in JVector left)

Parameters

left JVector

Returns

JVector

operator +(in JVector)

Returns the vector itself.

public static JVector operator +(in JVector left)

Parameters

left JVector

Returns

JVector