// Generated API outline. Implementation bodies omitted.
#nullable enable
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using System.Threading;
using System;
using nfloat = System.Runtime.InteropServices.NFloat;
using static Xui.Core.Math2D.Constants;
namespace Xui.Core.Math3D
{
using System.Runtime.CompilerServices;
///
/// 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 (which uses row-vector
/// convention) use the explicit cast operators, which perform the necessary transpose.
///
///
public struct Matrix4x4
{
/// Row 1, Column 1 — X basis X component (scale X for pure-scale matrices).
public float M11;
/// Row 1, Column 2 — X basis Y shear.
public float M12;
/// Row 1, Column 3 — X basis Z shear.
public float M13;
/// Row 1, Column 4 — Translation along X.
public float M14;
/// Row 2, Column 1 — Y basis X shear.
public float M21;
/// Row 2, Column 2 — Y basis Y component (scale Y for pure-scale matrices).
public float M22;
/// Row 2, Column 3 — Y basis Z shear.
public float M23;
/// Row 2, Column 4 — Translation along Y.
public float M24;
/// Row 3, Column 1 — Z basis X shear.
public float M31;
/// Row 3, Column 2 — Z basis Y shear.
public float M32;
/// Row 3, Column 3 — Z basis Z component (scale Z for pure-scale matrices).
public float M33;
/// Row 3, Column 4 — Translation along Z.
public float M34;
/// Row 4, Column 1 — Perspective X component (0 for affine transforms).
public float M41;
/// Row 4, Column 2 — Perspective Y component (0 for affine transforms).
public float M42;
/// Row 4, Column 3 — Perspective Z component (0 for affine transforms).
public float M43;
/// Row 4, Column 4 — Homogeneous W scale (1 for affine transforms).
public float M44;
/// The identity matrix.
public static readonly Matrix4x4 Identity;
///
/// Initializes a new with the specified row-ordered coefficients.
///
[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);
/// Returns true when this matrix equals the identity matrix.
public bool IsIdentity { get; }
///
/// Returns the transpose of this matrix (swaps rows and columns).
///
public Matrix4x4 Transposed { get; }
///
/// Returns the determinant of the matrix.
/// A determinant of zero means the matrix is not invertible.
///
public float Determinant { 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).
///
public Matrix4x4 Inverse { get; }
///
/// Creates a translation matrix that moves a point by the given vector.
///
[DebuggerStepThrough]
public static Matrix4x4 Translate(Vector3 v);
///
/// Creates a uniform scale matrix.
///
[DebuggerStepThrough]
public static Matrix4x4 Scale(float s);
///
/// Creates a non-uniform scale matrix.
///
[DebuggerStepThrough]
public static Matrix4x4 Scale(Vector3 v);
///
/// Creates a rotation matrix around the X axis by the given angle in radians.
///
[DebuggerStepThrough]
public static Matrix4x4 RotateX(float angle);
///
/// Creates a rotation matrix around the Y axis by the given angle in radians.
///
[DebuggerStepThrough]
public static Matrix4x4 RotateY(float angle);
///
/// Creates a rotation matrix around the Z axis by the given angle in radians.
///
[DebuggerStepThrough]
public static Matrix4x4 RotateZ(float angle);
///
/// Creates a rotation matrix from a unit quaternion.
///
[DebuggerStepThrough]
public static Matrix4x4 Rotate(Quaternion q);
///
/// Creates a symmetric perspective projection matrix (right-handed, depth range [-1, 1]).
///
/// Vertical field of view in radians.
/// Aspect ratio (width / height).
/// Distance to the near clipping plane (must be positive).
/// Distance to the far clipping plane (must be greater than ).
[DebuggerStepThrough]
public static Matrix4x4 Perspective(float fovY, float aspect, float near, float far);
///
/// Creates a look-at view matrix (right-handed coordinate system).
///
/// The position of the camera.
/// The position the camera is looking at.
/// The world up direction (typically ).
[DebuggerStepThrough]
public static Matrix4x4 LookAt(Point3 eye, Point3 target, Vector3 up);
///
/// Creates a symmetric orthographic projection matrix (right-handed, depth range [-1, 1]).
///
/// The width of the view volume.
/// The height of the view volume.
/// Distance to the near clipping plane.
/// Distance to the far clipping plane.
[DebuggerStepThrough]
public static Matrix4x4 Orthographic(float width, float height, float near, float far);
///
/// Composes two transformation matrices.
/// The result applies first, then .
///
[DebuggerStepThrough]
public static Matrix4x4 operator *(Matrix4x4 lhs, Matrix4x4 rhs);
///
/// Transforms a by this matrix, ignoring the translation component.
/// Use this for directions and normals.
///
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator *(Matrix4x4 m, Vector3 v);
///
/// Transforms a by this matrix, including the translation component.
/// Use this for positions.
///
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Point3 operator *(Matrix4x4 m, Point3 p);
/// Returns true if two matrices have equal coefficients.
[DebuggerStepThrough]
public static bool operator ==(Matrix4x4 lhs, Matrix4x4 rhs);
/// Returns true if any coefficient of two matrices differs.
[DebuggerStepThrough]
public static bool operator !=(Matrix4x4 lhs, Matrix4x4 rhs);
///
/// Explicitly converts to a .
///
///
/// 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.
///
[DebuggerStepThrough]
public static explicit operator System.Numerics.Matrix4x4(Matrix4x4 m);
///
/// Explicitly converts from a .
///
///
/// uses row-vector convention. This conversion
/// transposes the input matrix so that it works correctly with the column-vector
/// convention used by this type.
///
[DebuggerStepThrough]
public static explicit operator Matrix4x4(System.Numerics.Matrix4x4 m);
/// Indicates whether this instance and a specified object are equal.
/// The object to compare with the current instance.
///
/// if and this instance are the same type and represent the same value; otherwise, .
public override bool Equals(object? obj);
/// Returns true if this matrix equals another .
public bool Equals(Matrix4x4 other);
/// Returns the hash code for this instance.
/// A 32-bit signed integer that is the hash code for this instance.
public override int GetHashCode();
/// Returns the fully qualified type name of this instance.
/// The fully qualified type name.
public override string ToString();
}
///
/// Represents a point in 3D space defined by its X, Y, and Z coordinates.
///
///
/// A denotes a position. The difference of two points yields a
/// . Adding a to a offsets it.
///
public struct Point3
{
/// The X coordinate of the point.
public float X;
/// The Y coordinate of the point.
public float Y;
/// The Z coordinate of the point.
public float Z;
/// A point at the origin (0, 0, 0).
public static readonly Point3 Zero;
/// A point at (1, 1, 1).
public static readonly Point3 One;
///
/// Initializes a new with the specified coordinates.
///
/// The X coordinate.
/// The Y coordinate.
/// The Z coordinate.
[DebuggerStepThrough]
public Point3(float x, float y, float z);
///
/// Linearly interpolates between two points by the factor .
///
/// The start point at t = 0.
/// The end point at t = 1.
/// The interpolation factor, typically in the range [0, 1].
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Point3 Lerp(Point3 start, Point3 end, float t);
///
/// Returns the Euclidean distance between two points.
///
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Distance(Point3 a, Point3 b);
///
/// Returns the squared Euclidean distance between two points (no square root).
/// Useful for performance comparisons or ordering by proximity.
///
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float SquaredDistance(Point3 a, Point3 b);
///
/// Returns the Manhattan (taxicab) distance between two points.
/// This is the sum of the absolute differences of their coordinates.
///
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float TaxicabDistance(Point3 a, Point3 b);
///
/// Returns the vector from to .
///
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator -(Point3 lhs, Point3 rhs);
///
/// Offsets a point by a vector.
///
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Point3 operator +(Point3 p, Vector3 v);
///
/// Offsets a point in the opposite direction of a vector.
///
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Point3 operator -(Point3 p, Vector3 v);
///
/// Applies a uniform scale to a point relative to the origin.
///
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Point3 operator *(Point3 p, float f);
/// Determines whether two points have equal coordinates.
[DebuggerStepThrough]
public static bool operator ==(Point3 lhs, Point3 rhs);
/// Determines whether two points differ in any coordinate.
[DebuggerStepThrough]
public static bool operator !=(Point3 lhs, Point3 rhs);
/// Implicitly converts a tuple to a .
[DebuggerStepThrough]
public static implicit operator Point3((float x, float y, float z) t);
/// Explicitly converts a to a .
[DebuggerStepThrough]
public static explicit operator Point3(Vector3 v);
/// Indicates whether this instance and a specified object are equal.
/// The object to compare with the current instance.
///
/// if and this instance are the same type and represent the same value; otherwise, .
public override bool Equals(object? obj);
/// Returns true if this point has the same coordinates as another.
public bool Equals(Point3 other);
/// Returns the hash code for this instance.
/// A 32-bit signed integer that is the hash code for this instance.
public override int GetHashCode();
/// Returns the fully qualified type name of this instance.
/// The fully qualified type name.
public override string ToString();
}
///
/// 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
/// compatible with SIMD registers and GPU constant buffers.
///
///
public struct Quaternion
{
/// The X component of the vector part.
public float X;
/// The Y component of the vector part.
public float Y;
/// The Z component of the vector part.
public float Z;
/// The scalar (real) part of the quaternion.
public float W;
/// The identity quaternion representing no rotation.
public static readonly Quaternion Identity;
///
/// Initializes a new with the specified components.
///
/// The X component of the vector part.
/// The Y component of the vector part.
/// The Z component of the vector part.
/// The scalar (real) part.
[DebuggerStepThrough]
public Quaternion(float x, float y, float z, float w);
///
/// Returns the magnitude (norm) of the quaternion.
///
public float Magnitude {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; }
///
/// Returns the squared magnitude of the quaternion, avoiding a square root.
///
public float MagnitudeSquared {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; }
///
/// Returns a normalized (unit) copy of this quaternion.
/// Returns if the magnitude is zero.
///
public Quaternion Normalized {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; }
///
/// Returns the conjugate of the quaternion (negates the vector part).
/// For a unit quaternion, the conjugate equals the inverse.
///
public Quaternion Conjugate {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; }
///
/// Returns the inverse of the quaternion.
/// For a unit quaternion, prefer which is faster.
///
public Quaternion Inverse { get; }
///
/// Creates a quaternion representing a rotation of radians
/// around the given .
///
/// The axis of rotation (should be normalized).
/// The rotation angle in radians.
[DebuggerStepThrough]
public static Quaternion FromAxisAngle(Vector3 axis, float angle);
///
/// Creates a quaternion from Euler angles (in radians) applied in
/// Z (roll) → X (pitch) → Y (yaw) order (intrinsic rotations).
///
/// Rotation around the X axis in radians.
/// Rotation around the Y axis in radians.
/// Rotation around the Z axis in radians.
[DebuggerStepThrough]
public static Quaternion FromEuler(float pitch, float yaw, float roll);
///
/// Returns the dot product of two quaternions.
///
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Dot(Quaternion a, Quaternion b);
///
/// Linearly interpolates between two quaternions and normalizes the result.
///
/// The start quaternion at t = 0.
/// The end quaternion at t = 1.
/// The interpolation factor, typically in the range [0, 1].
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Quaternion Lerp(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.
///
/// The start rotation at t = 0.
/// The end rotation at t = 1.
/// The interpolation factor, typically in the range [0, 1].
[DebuggerStepThrough]
public static Quaternion Slerp(Quaternion a, Quaternion b, float t);
///
/// Multiplies two quaternions, composing their rotations.
/// The result applies first, then .
///
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Quaternion operator *(Quaternion lhs, Quaternion rhs);
///
/// Rotates a by this quaternion using the sandwich product:
/// v' = q * v * q⁻¹.
///
[DebuggerStepThrough]
public static Vector3 operator *(Quaternion q, Vector3 v);
///
/// Rotates a by this quaternion.
///
[DebuggerStepThrough]
public static Point3 operator *(Quaternion q, Point3 p);
///
/// Converts this quaternion to an equivalent 4×4 rotation matrix.
///
[DebuggerStepThrough]
public Matrix4x4 ToMatrix4x4();
///
/// 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°).
///
[DebuggerStepThrough]
public (float pitch, float yaw, float roll) ToEuler();
/// Returns true if two quaternions have equal components.
[DebuggerStepThrough]
public static bool operator ==(Quaternion lhs, Quaternion rhs);
/// Returns true if any component of two quaternions differs.
[DebuggerStepThrough]
public static bool operator !=(Quaternion lhs, Quaternion rhs);
///
/// Implicitly converts this quaternion to a
/// for use with SIMD-accelerated operations.
///
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator System.Numerics.Quaternion(Quaternion q);
///
/// Implicitly converts a to a .
///
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Quaternion(System.Numerics.Quaternion q);
/// Indicates whether this instance and a specified object are equal.
/// The object to compare with the current instance.
///
/// if and this instance are the same type and represent the same value; otherwise, .
public override bool Equals(object? obj);
/// Returns true if this quaternion equals another.
public bool Equals(Quaternion other);
/// Returns the hash code for this instance.
/// A 32-bit signed integer that is the hash code for this instance.
public override int GetHashCode();
/// Returns the fully qualified type name of this instance.
/// The fully qualified type name.
public override string ToString();
}
///
/// 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 for hardware-accelerated batch processing.
///
public struct Vector3
{
/// The X component of the vector.
public float X;
/// The Y component of the vector.
public float Y;
/// The Z component of the vector.
public float Z;
///
/// Initializes a new with the specified components.
///
/// The X component.
/// The Y component.
/// The Z component.
[DebuggerStepThrough]
public Vector3(float x, float y, float z);
/// A zero vector (0, 0, 0).
public static readonly Vector3 Zero;
/// A unit vector (1, 1, 1).
public static readonly Vector3 One;
/// A unit vector pointing right along the positive X axis (1, 0, 0).
public static readonly Vector3 Right;
/// A unit vector pointing left along the negative X axis (-1, 0, 0).
public static readonly Vector3 Left;
/// A unit vector pointing up along the positive Y axis (0, 1, 0).
public static readonly Vector3 Up;
/// A unit vector pointing down along the negative Y axis (0, -1, 0).
public static readonly Vector3 Down;
///
/// A unit vector pointing forward along the negative Z axis (0, 0, -1) in a right-handed coordinate system.
///
public static readonly Vector3 Forward;
/// A unit vector pointing backward along the positive Z axis (0, 0, 1).
public static readonly Vector3 Back;
///
/// Returns a normalized (unit length) copy of this vector.
/// Returns if the vector has zero magnitude.
///
public Vector3 Normalized {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; }
///
/// Returns the magnitude (length) of the vector.
///
public float Magnitude {[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.
///
public float MagnitudeSquared {[MethodImpl(MethodImplOptions.AggressiveInlining)]
get; }
///
/// Returns the dot product of two vectors.
///
/// The left-hand vector.
/// The right-hand vector.
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static float Dot(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.
///
/// The left-hand vector.
/// The right-hand vector.
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 Cross(Vector3 lhs, Vector3 rhs);
///
/// Projects onto .
/// Returns if has zero magnitude.
///
/// The vector to project.
/// The target direction vector.
[DebuggerStepThrough]
public static Vector3 Project(Vector3 lhs, Vector3 rhs);
///
/// Reflects the across the given surface .
/// The normal is assumed to be unit length.
///
/// The incident vector to reflect.
/// The surface normal (should be normalized).
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 Reflect(Vector3 vector, Vector3 normal);
///
/// Returns the angle in radians between two vectors.
/// Returns 0 if either vector has zero magnitude.
///
/// The first vector.
/// The second vector.
[DebuggerStepThrough]
public static float Angle(Vector3 lhs, Vector3 rhs);
///
/// Linearly interpolates between two vectors by the factor .
///
/// The start vector at t = 0.
/// The end vector at t = 1.
/// The interpolation factor, typically in the range [0, 1].
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 Lerp(Vector3 start, Vector3 end, float t);
///
/// Returns the component-wise minimum of two vectors.
///
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 Min(Vector3 lhs, Vector3 rhs);
///
/// Returns the component-wise maximum of two vectors.
///
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 Max(Vector3 lhs, Vector3 rhs);
/// Adds two vectors.
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator +(Vector3 lhs, Vector3 rhs);
/// Subtracts one vector from another.
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator -(Vector3 lhs, Vector3 rhs);
/// Negates a vector.
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator -(Vector3 v);
/// Multiplies a vector by a scalar.
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator *(Vector3 v, float f);
/// Multiplies a scalar by a vector.
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator *(float f, Vector3 v);
/// Divides a vector by a scalar.
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator /(Vector3 v, float f);
/// Multiplies two vectors component-wise.
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Vector3 operator *(Vector3 lhs, Vector3 rhs);
/// Returns true if two vectors have equal components.
[DebuggerStepThrough]
public static bool operator ==(Vector3 lhs, Vector3 rhs);
/// Returns true if any component of two vectors differs.
[DebuggerStepThrough]
public static bool operator !=(Vector3 lhs, Vector3 rhs);
/// Implicitly converts a tuple to a .
[DebuggerStepThrough]
public static implicit operator Vector3((float x, float y, float z) t);
/// Implicitly converts a to a .
[DebuggerStepThrough]
public static implicit operator Vector3(Point3 p);
///
/// Implicitly converts this vector to a
/// for use with SIMD-accelerated operations.
///
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator System.Numerics.Vector3(Vector3 v);
///
/// Implicitly converts a to a .
///
[DebuggerStepThrough]
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Vector3(System.Numerics.Vector3 v);
/// Indicates whether this instance and a specified object are equal.
/// The object to compare with the current instance.
///
/// if and this instance are the same type and represent the same value; otherwise, .
public override bool Equals(object? obj);
/// Returns true if this vector equals another .
public bool Equals(Vector3 other);
/// Returns the hash code for this instance.
/// A 32-bit signed integer that is the hash code for this instance.
public override int GetHashCode();
/// Returns the fully qualified type name of this instance.
/// The fully qualified type name.
public override string ToString();
}
}