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
xyzfloatThe 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
Fields
MaxValue
A vector with all components set to MaxValue.
public static readonly JVector MaxValue
Field Value
MinValue
A vector with all components set to MinValue.
public static readonly JVector MinValue
Field Value
One
A vector with all components set to one (1, 1, 1).
public static readonly JVector One
Field Value
UnitX
The unit vector along the X-axis (1, 0, 0).
public static readonly JVector UnitX
Field Value
UnitY
The unit vector along the Y-axis (0, 1, 0).
public static readonly JVector UnitY
Field Value
UnitZ
The unit vector along the Z-axis (0, 0, 1).
public static readonly JVector UnitZ
Field Value
X
public float X
Field Value
Y
public float Y
Field Value
Z
public float Z
Field Value
Zero
The zero vector (0, 0, 0).
public static readonly JVector Zero
Field Value
Properties
this[int]
public float this[int i] { get; set; }
Parameters
iint
Property Value
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
value1JVectorThe 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
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
value1JVectorThe first vector.
value2JVectorThe second vector.
resultJVectorOutput: 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
vectorJVectorThe vector to transform.
quatJQuaternionThe 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
vectorJVectorThe vector to transform.
quaternionJQuaternionThe quaternion (conjugated during operation).
resultJVectorOutput: 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
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
vector1JVectorThe first vector.
vector2JVectorThe second vector.
resultJVectorOutput: 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
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
otherJVectorAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override readonly bool Equals(object? obj)
Parameters
objobjectThe object to compare with the current instance.
Returns
- bool
true if
objand 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
LengthSquared()
Calculates the squared length of the vector (‖v‖²).
public readonly float LengthSquared()
Returns
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
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
value1JVectorThe first vector.
value2JVectorThe second vector.
resultJVectorOutput: 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
value1JVectorThe 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
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
value1JVectorThe first vector.
value2JVectorThe second vector.
resultJVectorOutput: 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
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
value1JVectorThe vector.
scaleFactorfloatThe scalar factor.
resultJVectorOutput: 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
valueJVectorThe 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
NegateInPlace(ref JVector)
Negates the vector in-place.
public static void NegateInPlace(ref JVector vector)
Parameters
vectorJVectorThe 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
valueJVectorThe 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
NormalizeInPlace(ref JVector)
Normalizes the vector in-place.
public static void NormalizeInPlace(ref JVector toNormalize)
Parameters
toNormalizeJVectorThe 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
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
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
Subtract(JVector, JVector)
Subtracts the second vector from the first.
public static JVector Subtract(JVector value1, JVector value2)
Parameters
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
value1JVectorThe first vector.
value2JVectorThe second vector.
resultJVectorOutput: 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
ToString()
Returns a string representation of the JVector.
public override readonly string ToString()
Returns
Transform(in JVector, in JMatrix)
Calculates matrix * vector (multiplying matrix by column vector).
public static JVector Transform(in JVector vector, in JMatrix matrix)
Parameters
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
vectorJVectorThe column vector.
matrixJMatrixThe matrix.
resultJVectorOutput: 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
vectorJVectorThe vector to transform.
quatJQuaternionThe 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
vectorJVectorThe vector to transform.
quaternionJQuaternionThe quaternion representing the rotation.
resultJVectorOutput: 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
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
vectorJVectorThe column vector.
matrixJMatrixThe matrix (transposed during operation).
resultJVectorOutput: 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
TThe 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
valueTThe value to reinterpret.
Returns
- JVector
The reinterpreted vector.
Type Parameters
TThe source unmanaged type.
Remarks
Valid only if T has identical size and compatible layout.
UnsafeGet(int)
public ref float UnsafeGet(int index)
Parameters
indexint
Returns
Operators
operator +(in JVector, in JVector)
Adds two vectors.
public static JVector operator +(in JVector value1, in JVector value2)
Parameters
Returns
operator ==(JVector, JVector)
public static bool operator ==(JVector value1, JVector value2)
Parameters
Returns
implicit operator Vector3(in JVector)
public static implicit operator Vector3(in JVector v)
Parameters
vJVector
Returns
implicit operator JVector(in Vector3)
public static implicit operator JVector(in Vector3 v)
Parameters
vVector3
Returns
implicit operator JVector((float x, float y, float z))
public static implicit operator JVector((float x, float y, float z) tuple)
Parameters
Returns
operator !=(JVector, JVector)
public static bool operator !=(JVector value1, JVector value2)
Parameters
Returns
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
Returns
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
Returns
operator *(in JVector, float)
Multiplies a vector by a scalar.
public static JVector operator *(in JVector value1, float value2)
Parameters
Returns
operator *(float, in JVector)
Multiplies a vector by a scalar.
public static JVector operator *(float value1, in JVector value2)
Parameters
Returns
operator -(in JVector, in JVector)
Subtracts the second vector from the first.
public static JVector operator -(in JVector value1, in JVector value2)
Parameters
Returns
operator -(in JVector)
Negates the vector.
public static JVector operator -(in JVector left)
Parameters
leftJVector
Returns
operator +(in JVector)
Returns the vector itself.
public static JVector operator +(in JVector left)
Parameters
leftJVector