Xui.Core.Math3D
Assembly: Xui.Core · C# declarations · Assembly overview
Types
struct Matrix4x4
Represents a 4×4 column-major transformation matrix for 3D geometry.
Vectors and points are treated as column vectors and transformed by pre-multiplication: v' = M * v. Translation is stored in the last column (M14, M24, M34).
The matrix is stored in row-major memory order (M_row_col) as 16 sequential floats (64 bytes), fitting exactly into four 128-bit SIMD registers.
To interoperate with System.Numerics.Matrix4x4 (which uses row-vector convention) use the explicit cast operators, which perform the necessary transpose.
public struct Matrix4x4
{
public float M11;
public float M12;
public float M13;
public float M14;
public float M21;
public float M22;
public float M23;
public float M24;
public float M31;
public float M32;
public float M33;
public float M34;
public float M41;
public float M42;
public float M43;
public float M44;
public static readonly Matrix4x4 Identity;
[DebuggerStepThrough]
public Matrix4x4(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44);
public bool IsIdentity { get; }
public Matrix4x4 Transposed { get; }
public float Determinant { get; }
public Matrix4x4 Inverse { get; }
[DebuggerStepThrough]
public static Matrix4x4 Translate(Vector3 v);
[DebuggerStepThrough]
public static Matrix4x4 Scale(float s);
[DebuggerStepThrough]
public static Matrix4x4 Scale(Vector3 v);
[DebuggerStepThrough]
public static Matrix4x4 RotateX(float angle);
[DebuggerStepThrough]
public static Matrix4x4 RotateY(float angle);
[DebuggerStepThrough]
public static Matrix4x4 RotateZ(float angle);
[DebuggerStepThrough]
public static Matrix4x4 Rotate(Quaternion q);
[DebuggerStepThrough]
public static Matrix4x4 Perspective(float fovY, float aspect, float near, float far);
[DebuggerStepThrough]
public static Matrix4x4 LookAt(Point3 eye, Point3 target, Vector3 up);
[DebuggerStepThrough]
public static Matrix4x4 Orthographic(float width, float height, float near, float far);
[DebuggerStepThrough]
public static Matrix4x4 operator *(Matrix4x4 lhs, Matrix4x4 rhs);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator *(Matrix4x4 m, Vector3 v);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Point3 operator *(Matrix4x4 m, Point3 p);
[DebuggerStepThrough]
public static bool operator ==(Matrix4x4 lhs, Matrix4x4 rhs);
[DebuggerStepThrough]
public static bool operator !=(Matrix4x4 lhs, Matrix4x4 rhs);
[DebuggerStepThrough]
public static explicit operator System.Numerics.Matrix4x4(Matrix4x4 m);
[DebuggerStepThrough]
public static explicit operator Matrix4x4(System.Numerics.Matrix4x4 m);
public override bool Equals(object? obj);
public bool Equals(Matrix4x4 other);
public override int GetHashCode();
public override string ToString();
}
Matrix4x4.Matrix4x4(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44)
[DebuggerStepThrough]
public Matrix4x4(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44);
Initializes a new Xui.Core.Math3D.Matrix4x4 with the specified row-ordered coefficients.
float Matrix4x4.Determinant
public float Determinant { get; }
Returns the determinant of the matrix. A determinant of zero means the matrix is not invertible.
bool Matrix4x4.Equals(object? obj)
public override bool Equals(object? obj);
Indicates whether this instance and a specified object are equal.
obj— The object to compare with the current instance.
Returns: true if obj and this instance are the same type and represent the same value; otherwise, false.
bool Matrix4x4.Equals(Matrix4x4 other)
public bool Equals(Matrix4x4 other);
Returns true if this matrix equals another Xui.Core.Math3D.Matrix4x4.
int Matrix4x4.GetHashCode()
public override int GetHashCode();
Returns the hash code for this instance.
Returns: A 32-bit signed integer that is the hash code for this instance.
Matrix4x4 Matrix4x4.Identity
public static readonly Matrix4x4 Identity;
The identity matrix.
Matrix4x4 Matrix4x4.Inverse
public Matrix4x4 Inverse { get; }
Returns the inverse of this matrix.
For rotation-only or TRS (translation-rotation-scale) matrices, consider computing the inverse analytically for better performance. Throws a division-by-zero style error if the matrix is singular (determinant ≈ 0).
bool Matrix4x4.IsIdentity
public bool IsIdentity { get; }
Returns true when this matrix equals the identity matrix.
Matrix4x4 Matrix4x4.LookAt(Point3 eye, Point3 target, Vector3 up)
[DebuggerStepThrough]
public static Matrix4x4 LookAt(Point3 eye, Point3 target, Vector3 up);
Creates a look-at view matrix (right-handed coordinate system).
eye— The position of the camera.target— The position the camera is looking at.up— The world up direction (typicallyXui.Core.Math3D.Vector3.Up).
float Matrix4x4.M11
public float M11;
Row 1, Column 1 — X basis X component (scale X for pure-scale matrices).
float Matrix4x4.M12
public float M12;
Row 1, Column 2 — X basis Y shear.
float Matrix4x4.M13
public float M13;
Row 1, Column 3 — X basis Z shear.
float Matrix4x4.M14
public float M14;
Row 1, Column 4 — Translation along X.
float Matrix4x4.M21
public float M21;
Row 2, Column 1 — Y basis X shear.
float Matrix4x4.M22
public float M22;
Row 2, Column 2 — Y basis Y component (scale Y for pure-scale matrices).
float Matrix4x4.M23
public float M23;
Row 2, Column 3 — Y basis Z shear.
float Matrix4x4.M24
public float M24;
Row 2, Column 4 — Translation along Y.
float Matrix4x4.M31
public float M31;
Row 3, Column 1 — Z basis X shear.
float Matrix4x4.M32
public float M32;
Row 3, Column 2 — Z basis Y shear.
float Matrix4x4.M33
public float M33;
Row 3, Column 3 — Z basis Z component (scale Z for pure-scale matrices).
float Matrix4x4.M34
public float M34;
Row 3, Column 4 — Translation along Z.
float Matrix4x4.M41
public float M41;
Row 4, Column 1 — Perspective X component (0 for affine transforms).
float Matrix4x4.M42
public float M42;
Row 4, Column 2 — Perspective Y component (0 for affine transforms).
float Matrix4x4.M43
public float M43;
Row 4, Column 3 — Perspective Z component (0 for affine transforms).
float Matrix4x4.M44
public float M44;
Row 4, Column 4 — Homogeneous W scale (1 for affine transforms).
Matrix4x4 Matrix4x4.Orthographic(float width, float height, float near, float far)
[DebuggerStepThrough]
public static Matrix4x4 Orthographic(float width, float height, float near, float far);
Creates a symmetric orthographic projection matrix (right-handed, depth range [-1, 1]).
width— The width of the view volume.height— The height of the view volume.near— Distance to the near clipping plane.far— Distance to the far clipping plane.
Matrix4x4 Matrix4x4.Perspective(float fovY, float aspect, float near, float far)
[DebuggerStepThrough]
public static Matrix4x4 Perspective(float fovY, float aspect, float near, float far);
Creates a symmetric perspective projection matrix (right-handed, depth range [-1, 1]).
fovY— Vertical field of view in radians.aspect— Aspect ratio (width / height).near— Distance to the near clipping plane (must be positive).far— Distance to the far clipping plane (must be greater thannear).
Matrix4x4 Matrix4x4.Rotate(Quaternion q)
[DebuggerStepThrough]
public static Matrix4x4 Rotate(Quaternion q);
Creates a rotation matrix from a unit quaternion.
Matrix4x4 Matrix4x4.RotateX(float angle)
[DebuggerStepThrough]
public static Matrix4x4 RotateX(float angle);
Creates a rotation matrix around the X axis by the given angle in radians.
Matrix4x4 Matrix4x4.RotateY(float angle)
[DebuggerStepThrough]
public static Matrix4x4 RotateY(float angle);
Creates a rotation matrix around the Y axis by the given angle in radians.
Matrix4x4 Matrix4x4.RotateZ(float angle)
[DebuggerStepThrough]
public static Matrix4x4 RotateZ(float angle);
Creates a rotation matrix around the Z axis by the given angle in radians.
Matrix4x4 Matrix4x4.Scale(float s)
[DebuggerStepThrough]
public static Matrix4x4 Scale(float s);
Creates a uniform scale matrix.
Matrix4x4 Matrix4x4.Scale(Vector3 v)
[DebuggerStepThrough]
public static Matrix4x4 Scale(Vector3 v);
Creates a non-uniform scale matrix.
string Matrix4x4.ToString()
public override string ToString();
Returns the fully qualified type name of this instance.
Returns: The fully qualified type name.
Matrix4x4 Matrix4x4.Translate(Vector3 v)
[DebuggerStepThrough]
public static Matrix4x4 Translate(Vector3 v);
Creates a translation matrix that moves a point by the given vector.
Matrix4x4 Matrix4x4.Transposed
public Matrix4x4 Transposed { get; }
Returns the transpose of this matrix (swaps rows and columns).
bool Matrix4x4.operator ==(Matrix4x4 lhs, Matrix4x4 rhs)
[DebuggerStepThrough]
public static bool operator ==(Matrix4x4 lhs, Matrix4x4 rhs);
Returns true if two matrices have equal coefficients.
Matrix4x4.explicit operator Matrix4x4(Matrix4x4 m)
[DebuggerStepThrough]
public static explicit operator Matrix4x4(System.Numerics.Matrix4x4 m);
Explicitly converts from a System.Numerics.Matrix4x4.
System.Numerics.Matrix4x4 uses row-vector convention. This conversion transposes the input matrix so that it works correctly with the column-vector convention used by this type.
Matrix4x4.explicit operator Matrix4x4(Matrix4x4 m)
[DebuggerStepThrough]
public static explicit operator System.Numerics.Matrix4x4(Matrix4x4 m);
Explicitly converts to a System.Numerics.Matrix4x4.
System.Numerics.Matrix4x4 uses row-vector convention, which is the transpose of the column-vector convention used by this type. The conversion transposes the matrix so that row-vector math on the result produces the same geometric transformation.
bool Matrix4x4.operator !=(Matrix4x4 lhs, Matrix4x4 rhs)
[DebuggerStepThrough]
public static bool operator !=(Matrix4x4 lhs, Matrix4x4 rhs);
Returns true if any coefficient of two matrices differs.
Matrix4x4 Matrix4x4.operator *(Matrix4x4 lhs, Matrix4x4 rhs)
[DebuggerStepThrough]
public static Matrix4x4 operator *(Matrix4x4 lhs, Matrix4x4 rhs);
Composes two transformation matrices. The result applies rhs first, then lhs.
Point3 Matrix4x4.operator *(Matrix4x4 m, Point3 p)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Point3 operator *(Matrix4x4 m, Point3 p);
Transforms a Xui.Core.Math3D.Point3 by this matrix, including the translation component. Use this for positions.
Vector3 Matrix4x4.operator *(Matrix4x4 m, Vector3 v)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator *(Matrix4x4 m, Vector3 v);
Transforms a Xui.Core.Math3D.Vector3 by this matrix, ignoring the translation component. Use this for directions and normals.
struct Point3
Represents a point in 3D space defined by its X, Y, and Z coordinates.
A Xui.Core.Math3D.Point3 denotes a position. The difference of two points yields a Xui.Core.Math3D.Vector3. Adding a Xui.Core.Math3D.Vector3 to a Xui.Core.Math3D.Point3 offsets it.
public struct Point3
{
public float X;
public float Y;
public float Z;
public static readonly Point3 Zero;
public static readonly Point3 One;
[DebuggerStepThrough]
public Point3(float x, float y, float z);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Point3 Lerp(Point3 start, Point3 end, float t);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Distance(Point3 a, Point3 b);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float SquaredDistance(Point3 a, Point3 b);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float TaxicabDistance(Point3 a, Point3 b);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator -(Point3 lhs, Point3 rhs);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Point3 operator +(Point3 p, Vector3 v);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Point3 operator -(Point3 p, Vector3 v);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Point3 operator *(Point3 p, float f);
[DebuggerStepThrough]
public static bool operator ==(Point3 lhs, Point3 rhs);
[DebuggerStepThrough]
public static bool operator !=(Point3 lhs, Point3 rhs);
[DebuggerStepThrough]
public static implicit operator Point3((float x, float y, float z) t);
[DebuggerStepThrough]
public static explicit operator Point3(Vector3 v);
public override bool Equals(object? obj);
public bool Equals(Point3 other);
public override int GetHashCode();
public override string ToString();
}
Point3.Point3(float x, float y, float z)
[DebuggerStepThrough]
public Point3(float x, float y, float z);
Initializes a new Xui.Core.Math3D.Point3 with the specified coordinates.
x— The X coordinate.y— The Y coordinate.z— The Z coordinate.
float Point3.Distance(Point3 a, Point3 b)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Distance(Point3 a, Point3 b);
Returns the Euclidean distance between two points.
bool Point3.Equals(object? obj)
public override bool Equals(object? obj);
Indicates whether this instance and a specified object are equal.
obj— The object to compare with the current instance.
Returns: true if obj and this instance are the same type and represent the same value; otherwise, false.
bool Point3.Equals(Point3 other)
public bool Equals(Point3 other);
Returns true if this point has the same coordinates as another.
int Point3.GetHashCode()
public override int GetHashCode();
Returns the hash code for this instance.
Returns: A 32-bit signed integer that is the hash code for this instance.
Point3 Point3.Lerp(Point3 start, Point3 end, float t)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Point3 Lerp(Point3 start, Point3 end, float t);
Linearly interpolates between two points by the factor t.
start— The start point at t = 0.end— The end point at t = 1.t— The interpolation factor, typically in the range [0, 1].
Point3 Point3.One
public static readonly Point3 One;
A point at (1, 1, 1).
float Point3.SquaredDistance(Point3 a, Point3 b)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float SquaredDistance(Point3 a, Point3 b);
Returns the squared Euclidean distance between two points (no square root). Useful for performance comparisons or ordering by proximity.
float Point3.TaxicabDistance(Point3 a, Point3 b)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float TaxicabDistance(Point3 a, Point3 b);
Returns the Manhattan (taxicab) distance between two points. This is the sum of the absolute differences of their coordinates.
string Point3.ToString()
public override string ToString();
Returns the fully qualified type name of this instance.
Returns: The fully qualified type name.
float Point3.X
public float X;
The X coordinate of the point.
float Point3.Y
public float Y;
The Y coordinate of the point.
float Point3.Z
public float Z;
The Z coordinate of the point.
Point3 Point3.Zero
public static readonly Point3 Zero;
A point at the origin (0, 0, 0).
Point3 Point3.operator +(Point3 p, Vector3 v)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Point3 operator +(Point3 p, Vector3 v);
Offsets a point by a vector.
bool Point3.operator ==(Point3 lhs, Point3 rhs)
[DebuggerStepThrough]
public static bool operator ==(Point3 lhs, Point3 rhs);
Determines whether two points have equal coordinates.
Point3.explicit operator Point3(Vector3 v)
[DebuggerStepThrough]
public static explicit operator Point3(Vector3 v);
Explicitly converts a Xui.Core.Math3D.Vector3 to a Xui.Core.Math3D.Point3.
Point3.implicit operator Point3((float x, float y, float z) t)
[DebuggerStepThrough]
public static implicit operator Point3((float x, float y, float z) t);
Implicitly converts a tuple to a Xui.Core.Math3D.Point3.
bool Point3.operator !=(Point3 lhs, Point3 rhs)
[DebuggerStepThrough]
public static bool operator !=(Point3 lhs, Point3 rhs);
Determines whether two points differ in any coordinate.
Point3 Point3.operator *(Point3 p, float f)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Point3 operator *(Point3 p, float f);
Applies a uniform scale to a point relative to the origin.
Vector3 Point3.operator -(Point3 lhs, Point3 rhs)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator -(Point3 lhs, Point3 rhs);
Returns the vector from rhs to lhs.
Point3 Point3.operator -(Point3 p, Vector3 v)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Point3 operator -(Point3 p, Vector3 v);
Offsets a point in the opposite direction of a vector.
struct Quaternion
Represents a unit quaternion used to encode a 3D rotation.
A quaternion is stored as four floats (X, Y, Z, W) where (X, Y, Z) is the vector part and W is the scalar part. For a rotation of angle θ around a normalized axis n: X = n.X·sin(θ/2), Y = n.Y·sin(θ/2), Z = n.Z·sin(θ/2), W = cos(θ/2).
The 16-byte memory layout (four sequential floats) makes Xui.Core.Math3D.Quaternion compatible with SIMD registers and GPU constant buffers.
public struct Quaternion
{
public float X;
public float Y;
public float Z;
public float W;
public static readonly Quaternion Identity;
[DebuggerStepThrough]
public Quaternion(float x, float y, float z, float w);
public float Magnitude {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; }
public float MagnitudeSquared {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; }
public Quaternion Normalized {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; }
public Quaternion Conjugate {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; }
public Quaternion Inverse { get; }
[DebuggerStepThrough]
public static Quaternion FromAxisAngle(Vector3 axis, float angle);
[DebuggerStepThrough]
public static Quaternion FromEuler(float pitch, float yaw, float roll);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Dot(Quaternion a, Quaternion b);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Quaternion Lerp(Quaternion a, Quaternion b, float t);
[DebuggerStepThrough]
public static Quaternion Slerp(Quaternion a, Quaternion b, float t);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Quaternion operator *(Quaternion lhs, Quaternion rhs);
[DebuggerStepThrough]
public static Vector3 operator *(Quaternion q, Vector3 v);
[DebuggerStepThrough]
public static Point3 operator *(Quaternion q, Point3 p);
[DebuggerStepThrough]
public Matrix4x4 ToMatrix4x4();
[DebuggerStepThrough]
public (float pitch, float yaw, float roll) ToEuler();
[DebuggerStepThrough]
public static bool operator ==(Quaternion lhs, Quaternion rhs);
[DebuggerStepThrough]
public static bool operator !=(Quaternion lhs, Quaternion rhs);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator System.Numerics.Quaternion(Quaternion q);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Quaternion(System.Numerics.Quaternion q);
public override bool Equals(object? obj);
public bool Equals(Quaternion other);
public override int GetHashCode();
public override string ToString();
}
Quaternion.Quaternion(float x, float y, float z, float w)
[DebuggerStepThrough]
public Quaternion(float x, float y, float z, float w);
Initializes a new Xui.Core.Math3D.Quaternion with the specified components.
x— The X component of the vector part.y— The Y component of the vector part.z— The Z component of the vector part.w— The scalar (real) part.
Quaternion Quaternion.Conjugate
public Quaternion Conjugate {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; }
Returns the conjugate of the quaternion (negates the vector part). For a unit quaternion, the conjugate equals the inverse.
float Quaternion.Dot(Quaternion a, Quaternion b)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Dot(Quaternion a, Quaternion b);
Returns the dot product of two quaternions.
bool Quaternion.Equals(object? obj)
public override bool Equals(object? obj);
Indicates whether this instance and a specified object are equal.
obj— The object to compare with the current instance.
Returns: true if obj and this instance are the same type and represent the same value; otherwise, false.
bool Quaternion.Equals(Quaternion other)
public bool Equals(Quaternion other);
Returns true if this quaternion equals another.
Quaternion Quaternion.FromAxisAngle(Vector3 axis, float angle)
[DebuggerStepThrough]
public static Quaternion FromAxisAngle(Vector3 axis, float angle);
Creates a quaternion representing a rotation of angle radians around the given axis.
axis— The axis of rotation (should be normalized).angle— The rotation angle in radians.
Quaternion Quaternion.FromEuler(float pitch, float yaw, float roll)
[DebuggerStepThrough]
public static Quaternion FromEuler(float pitch, float yaw, float roll);
Creates a quaternion from Euler angles (in radians) applied in Z (roll) → X (pitch) → Y (yaw) order (intrinsic rotations).
pitch— Rotation around the X axis in radians.yaw— Rotation around the Y axis in radians.roll— Rotation around the Z axis in radians.
int Quaternion.GetHashCode()
public override int GetHashCode();
Returns the hash code for this instance.
Returns: A 32-bit signed integer that is the hash code for this instance.
Quaternion Quaternion.Identity
public static readonly Quaternion Identity;
The identity quaternion representing no rotation.
Quaternion Quaternion.Inverse
public Quaternion Inverse { get; }
Returns the inverse of the quaternion. For a unit quaternion, prefer Xui.Core.Math3D.Quaternion.Conjugate which is faster.
Quaternion Quaternion.Lerp(Quaternion a, Quaternion b, float t)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Quaternion Lerp(Quaternion a, Quaternion b, float t);
Linearly interpolates between two quaternions and normalizes the result.
a— The start quaternion at t = 0.b— The end quaternion at t = 1.t— The interpolation factor, typically in the range [0, 1].
float Quaternion.Magnitude
public float Magnitude {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; }
Returns the magnitude (norm) of the quaternion.
float Quaternion.MagnitudeSquared
public float MagnitudeSquared {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; }
Returns the squared magnitude of the quaternion, avoiding a square root.
Quaternion Quaternion.Normalized
public Quaternion Normalized {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; }
Returns a normalized (unit) copy of this quaternion. Returns Xui.Core.Math3D.Quaternion.Identity if the magnitude is zero.
Quaternion Quaternion.Slerp(Quaternion a, Quaternion b, float t)
[DebuggerStepThrough]
public static Quaternion Slerp(Quaternion a, Quaternion b, float t);
Performs spherical linear interpolation (Slerp) between two unit quaternions. Produces a constant-speed rotation along the shortest arc on the unit 4-sphere.
a— The start rotation at t = 0.b— The end rotation at t = 1.t— The interpolation factor, typically in the range [0, 1].
(float pitch, float yaw, float roll) Quaternion.ToEuler()
[DebuggerStepThrough]
public (float pitch, float yaw, float roll) ToEuler();
Decomposes this quaternion into Euler angles (pitch, yaw, roll) in radians.
The angles are in the range [-π, π] for pitch, yaw, and roll. Gimbal lock may occur near the poles of pitch (±90°).
Matrix4x4 Quaternion.ToMatrix4x4()
[DebuggerStepThrough]
public Matrix4x4 ToMatrix4x4();
Converts this quaternion to an equivalent 4×4 rotation matrix.
string Quaternion.ToString()
public override string ToString();
Returns the fully qualified type name of this instance.
Returns: The fully qualified type name.
float Quaternion.W
public float W;
The scalar (real) part of the quaternion.
float Quaternion.X
public float X;
The X component of the vector part.
float Quaternion.Y
public float Y;
The Y component of the vector part.
float Quaternion.Z
public float Z;
The Z component of the vector part.
bool Quaternion.operator ==(Quaternion lhs, Quaternion rhs)
[DebuggerStepThrough]
public static bool operator ==(Quaternion lhs, Quaternion rhs);
Returns true if two quaternions have equal components.
Quaternion.implicit operator Quaternion(Quaternion q)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Quaternion(System.Numerics.Quaternion q);
Implicitly converts a System.Numerics.Quaternion to a Xui.Core.Math3D.Quaternion.
Quaternion.implicit operator Quaternion(Quaternion q)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator System.Numerics.Quaternion(Quaternion q);
Implicitly converts this quaternion to a System.Numerics.Quaternion for use with SIMD-accelerated operations.
bool Quaternion.operator !=(Quaternion lhs, Quaternion rhs)
[DebuggerStepThrough]
public static bool operator !=(Quaternion lhs, Quaternion rhs);
Returns true if any component of two quaternions differs.
Point3 Quaternion.operator *(Quaternion q, Point3 p)
[DebuggerStepThrough]
public static Point3 operator *(Quaternion q, Point3 p);
Rotates a Xui.Core.Math3D.Point3 by this quaternion.
Quaternion Quaternion.operator *(Quaternion lhs, Quaternion rhs)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Quaternion operator *(Quaternion lhs, Quaternion rhs);
Multiplies two quaternions, composing their rotations. The result applies rhs first, then lhs.
Vector3 Quaternion.operator *(Quaternion q, Vector3 v)
[DebuggerStepThrough]
public static Vector3 operator *(Quaternion q, Vector3 v);
Rotates a Xui.Core.Math3D.Vector3 by this quaternion using the sandwich product: v' = q * v * q⁻¹.
struct Vector3
Represents a 3D vector with X, Y, and Z components. Commonly used for geometric operations, physics, lighting, and 3D movement.
The struct is laid out sequentially as three 32-bit floats (12 bytes), making it directly compatible with SIMD operations and GPU shader inputs. Use System.Numerics.Vector3 for hardware-accelerated batch processing.
public struct Vector3
{
public float X;
public float Y;
public float Z;
[DebuggerStepThrough]
public Vector3(float x, float y, float z);
public static readonly Vector3 Zero;
public static readonly Vector3 One;
public static readonly Vector3 Right;
public static readonly Vector3 Left;
public static readonly Vector3 Up;
public static readonly Vector3 Down;
public static readonly Vector3 Forward;
public static readonly Vector3 Back;
public Vector3 Normalized {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; }
public float Magnitude {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; }
public float MagnitudeSquared {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; }
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Dot(Vector3 lhs, Vector3 rhs);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 Cross(Vector3 lhs, Vector3 rhs);
[DebuggerStepThrough]
public static Vector3 Project(Vector3 lhs, Vector3 rhs);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 Reflect(Vector3 vector, Vector3 normal);
[DebuggerStepThrough]
public static float Angle(Vector3 lhs, Vector3 rhs);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 Lerp(Vector3 start, Vector3 end, float t);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 Min(Vector3 lhs, Vector3 rhs);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 Max(Vector3 lhs, Vector3 rhs);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator +(Vector3 lhs, Vector3 rhs);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator -(Vector3 lhs, Vector3 rhs);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator -(Vector3 v);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator *(Vector3 v, float f);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator *(float f, Vector3 v);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator /(Vector3 v, float f);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator *(Vector3 lhs, Vector3 rhs);
[DebuggerStepThrough]
public static bool operator ==(Vector3 lhs, Vector3 rhs);
[DebuggerStepThrough]
public static bool operator !=(Vector3 lhs, Vector3 rhs);
[DebuggerStepThrough]
public static implicit operator Vector3((float x, float y, float z) t);
[DebuggerStepThrough]
public static implicit operator Vector3(Point3 p);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator System.Numerics.Vector3(Vector3 v);
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Vector3(System.Numerics.Vector3 v);
public override bool Equals(object? obj);
public bool Equals(Vector3 other);
public override int GetHashCode();
public override string ToString();
}
Vector3.Vector3(float x, float y, float z)
[DebuggerStepThrough]
public Vector3(float x, float y, float z);
Initializes a new Xui.Core.Math3D.Vector3 with the specified components.
x— The X component.y— The Y component.z— The Z component.
float Vector3.Angle(Vector3 lhs, Vector3 rhs)
[DebuggerStepThrough]
public static float Angle(Vector3 lhs, Vector3 rhs);
Returns the angle in radians between two vectors. Returns 0 if either vector has zero magnitude.
lhs— The first vector.rhs— The second vector.
Vector3 Vector3.Back
public static readonly Vector3 Back;
A unit vector pointing backward along the positive Z axis (0, 0, 1).
Vector3 Vector3.Cross(Vector3 lhs, Vector3 rhs)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 Cross(Vector3 lhs, Vector3 rhs);
Returns the cross product of two vectors. The result is a vector perpendicular to both inputs, with direction determined by the right-hand rule.
lhs— The left-hand vector.rhs— The right-hand vector.
float Vector3.Dot(Vector3 lhs, Vector3 rhs)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Dot(Vector3 lhs, Vector3 rhs);
Returns the dot product of two vectors.
lhs— The left-hand vector.rhs— The right-hand vector.
Vector3 Vector3.Down
public static readonly Vector3 Down;
A unit vector pointing down along the negative Y axis (0, -1, 0).
bool Vector3.Equals(object? obj)
public override bool Equals(object? obj);
Indicates whether this instance and a specified object are equal.
obj— The object to compare with the current instance.
Returns: true if obj and this instance are the same type and represent the same value; otherwise, false.
bool Vector3.Equals(Vector3 other)
public bool Equals(Vector3 other);
Returns true if this vector equals another Xui.Core.Math3D.Vector3.
Vector3 Vector3.Forward
public static readonly Vector3 Forward;
A unit vector pointing forward along the negative Z axis (0, 0, -1) in a right-handed coordinate system.
int Vector3.GetHashCode()
public override int GetHashCode();
Returns the hash code for this instance.
Returns: A 32-bit signed integer that is the hash code for this instance.
Vector3 Vector3.Left
public static readonly Vector3 Left;
A unit vector pointing left along the negative X axis (-1, 0, 0).
Vector3 Vector3.Lerp(Vector3 start, Vector3 end, float t)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 Lerp(Vector3 start, Vector3 end, float t);
Linearly interpolates between two vectors by the factor t.
start— The start vector at t = 0.end— The end vector at t = 1.t— The interpolation factor, typically in the range [0, 1].
float Vector3.Magnitude
public float Magnitude {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; }
Returns the magnitude (length) of the vector.
float Vector3.MagnitudeSquared
public float MagnitudeSquared {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; }
Returns the squared magnitude of the vector, avoiding a square root computation. Useful for distance comparisons where the exact length is not needed.
Vector3 Vector3.Max(Vector3 lhs, Vector3 rhs)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 Max(Vector3 lhs, Vector3 rhs);
Returns the component-wise maximum of two vectors.
Vector3 Vector3.Min(Vector3 lhs, Vector3 rhs)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 Min(Vector3 lhs, Vector3 rhs);
Returns the component-wise minimum of two vectors.
Vector3 Vector3.Normalized
public Vector3 Normalized {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; }
Returns a normalized (unit length) copy of this vector. Returns Xui.Core.Math3D.Vector3.Zero if the vector has zero magnitude.
Vector3 Vector3.One
public static readonly Vector3 One;
A unit vector (1, 1, 1).
Vector3 Vector3.Project(Vector3 lhs, Vector3 rhs)
[DebuggerStepThrough]
public static Vector3 Project(Vector3 lhs, Vector3 rhs);
Projects lhs onto rhs. Returns Xui.Core.Math3D.Vector3.Zero if rhs has zero magnitude.
lhs— The vector to project.rhs— The target direction vector.
Vector3 Vector3.Reflect(Vector3 vector, Vector3 normal)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 Reflect(Vector3 vector, Vector3 normal);
Reflects the vector across the given surface normal. The normal is assumed to be unit length.
vector— The incident vector to reflect.normal— The surface normal (should be normalized).
Vector3 Vector3.Right
public static readonly Vector3 Right;
A unit vector pointing right along the positive X axis (1, 0, 0).
string Vector3.ToString()
public override string ToString();
Returns the fully qualified type name of this instance.
Returns: The fully qualified type name.
Vector3 Vector3.Up
public static readonly Vector3 Up;
A unit vector pointing up along the positive Y axis (0, 1, 0).
float Vector3.X
public float X;
The X component of the vector.
float Vector3.Y
public float Y;
The Y component of the vector.
float Vector3.Z
public float Z;
The Z component of the vector.
Vector3 Vector3.Zero
public static readonly Vector3 Zero;
A zero vector (0, 0, 0).
Vector3 Vector3.operator +(Vector3 lhs, Vector3 rhs)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator +(Vector3 lhs, Vector3 rhs);
Adds two vectors.
Vector3 Vector3.operator /(Vector3 v, float f)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator /(Vector3 v, float f);
Divides a vector by a scalar.
bool Vector3.operator ==(Vector3 lhs, Vector3 rhs)
[DebuggerStepThrough]
public static bool operator ==(Vector3 lhs, Vector3 rhs);
Returns true if two vectors have equal components.
Vector3.implicit operator Vector3(Vector3 v)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Vector3(System.Numerics.Vector3 v);
Implicitly converts a System.Numerics.Vector3 to a Xui.Core.Math3D.Vector3.
Vector3.implicit operator Vector3((float x, float y, float z) t)
[DebuggerStepThrough]
public static implicit operator Vector3((float x, float y, float z) t);
Implicitly converts a tuple to a Xui.Core.Math3D.Vector3.
Vector3.implicit operator Vector3(Point3 p)
[DebuggerStepThrough]
public static implicit operator Vector3(Point3 p);
Implicitly converts a Xui.Core.Math3D.Point3 to a Xui.Core.Math3D.Vector3.
Vector3.implicit operator Vector3(Vector3 v)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator System.Numerics.Vector3(Vector3 v);
Implicitly converts this vector to a System.Numerics.Vector3 for use with SIMD-accelerated operations.
bool Vector3.operator !=(Vector3 lhs, Vector3 rhs)
[DebuggerStepThrough]
public static bool operator !=(Vector3 lhs, Vector3 rhs);
Returns true if any component of two vectors differs.
Vector3 Vector3.operator *(float f, Vector3 v)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator *(float f, Vector3 v);
Multiplies a scalar by a vector.
Vector3 Vector3.operator *(Vector3 v, float f)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator *(Vector3 v, float f);
Multiplies a vector by a scalar.
Vector3 Vector3.operator *(Vector3 lhs, Vector3 rhs)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator *(Vector3 lhs, Vector3 rhs);
Multiplies two vectors component-wise.
Vector3 Vector3.operator -(Vector3 lhs, Vector3 rhs)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator -(Vector3 lhs, Vector3 rhs);
Subtracts one vector from another.
Vector3 Vector3.operator -(Vector3 v)
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator -(Vector3 v);
Negates a vector.