Xui.Core.Math2D
Assembly: Xui.Core · C# declarations · Assembly overview
Types
struct AffineTransformclass Constantsstruct Framestruct Pointstruct Rectstruct Sizestruct Vector
struct AffineTransform
Represents a 2D affine transformation matrix in the form:
| A C Tx |
| B D Ty |
| 0 0 1 |
Used for rotating, scaling, translating, and skewing 2D vectors or points.
Transformation is applied as:
| x' | | A C Tx | | x |
| y' | = | B D Ty | * | y |
| 1 | | 0 0 1 | | 1 |
public struct AffineTransform
{
public nfloat A;
public nfloat B;
public nfloat C;
public nfloat D;
public nfloat Tx;
public nfloat Ty;
public static readonly AffineTransform Identity;
public bool IsIdentity { get; }
public AffineTransform Inverse {[DebuggerStepThrough]
get; }
public nfloat Determinant {[DebuggerStepThrough]
get; }
[DebuggerStepThrough]
public static AffineTransform Rotate(nfloat angle);
[DebuggerStepThrough]
public static AffineTransform Translate(Vector v);
[DebuggerStepThrough]
public static AffineTransform Scale(Vector v);
[DebuggerStepThrough]
public static AffineTransform Shear(nfloat shearX, nfloat shearY);
[DebuggerStepThrough]
public AffineTransform(nfloat a, nfloat b, nfloat c, nfloat d, nfloat tx, nfloat ty);
[DebuggerStepThrough]
public static Vector operator *(AffineTransform t, Vector v);
[DebuggerStepThrough]
public static Point operator *(AffineTransform t, Point p);
[DebuggerStepThrough]
public static AffineTransform operator *(AffineTransform lhs, AffineTransform rhs);
[DebuggerStepThrough]
public override string ToString();
}
AffineTransform.AffineTransform(NFloat a, NFloat b, NFloat c, NFloat d, NFloat tx, NFloat ty)
[DebuggerStepThrough]
public AffineTransform(nfloat a, nfloat b, nfloat c, nfloat d, nfloat tx, nfloat ty);
Constructs an affine transform with the specified matrix coefficients.
NFloat AffineTransform.A
public nfloat A;
The matrix component in the first row, first column (scale X / rotate).
NFloat AffineTransform.B
public nfloat B;
The matrix component in the second row, first column (shear Y / rotate).
NFloat AffineTransform.C
public nfloat C;
The matrix component in the first row, second column (shear X / rotate).
NFloat AffineTransform.D
public nfloat D;
The matrix component in the second row, second column (scale Y / rotate).
NFloat AffineTransform.Determinant
public nfloat Determinant {[DebuggerStepThrough]
get; }
Returns the determinant of the 2×2 linear portion of the matrix.
This value determines if the matrix is invertible. A value of 0 means the matrix cannot be inverted.
AffineTransform AffineTransform.Identity
public static readonly AffineTransform Identity;
The identity transform (no scale, rotation, or translation).
AffineTransform AffineTransform.Inverse
public AffineTransform Inverse {[DebuggerStepThrough]
get; }
Returns the inverse of this affine transform.
This operation assumes the transform is invertible. Division by a zero determinant will cause a runtime exception.
bool AffineTransform.IsIdentity
public bool IsIdentity { get; }
Returns true if the current transform is the identity matrix.
AffineTransform AffineTransform.Rotate(NFloat angle)
[DebuggerStepThrough]
public static AffineTransform Rotate(nfloat angle);
Creates a rotation transform around the origin using the given angle in radians.
AffineTransform AffineTransform.Scale(Vector v)
[DebuggerStepThrough]
public static AffineTransform Scale(Vector v);
Creates a scaling transform using the specified scale vector.
AffineTransform AffineTransform.Shear(NFloat shearX, NFloat shearY)
[DebuggerStepThrough]
public static AffineTransform Shear(nfloat shearX, nfloat shearY);
Creates a shear (skew) transformation along the X and Y axes.
shearX— The shear factor in the X direction.shearY— The shear factor in the Y direction.
string AffineTransform.ToString()
[DebuggerStepThrough]
public override string ToString();
Returns the fully qualified type name of this instance.
Returns: The fully qualified type name.
AffineTransform AffineTransform.Translate(Vector v)
[DebuggerStepThrough]
public static AffineTransform Translate(Vector v);
Creates a translation transform using the specified offset vector.
NFloat AffineTransform.Tx
public nfloat Tx;
The translation component along the X axis.
NFloat AffineTransform.Ty
public nfloat Ty;
The translation component along the Y axis.
AffineTransform AffineTransform.operator *(AffineTransform lhs, AffineTransform rhs)
[DebuggerStepThrough]
public static AffineTransform operator *(AffineTransform lhs, AffineTransform rhs);
Composes two affine transforms using matrix multiplication.
Returns: A new transform representing the application of rhs followed by lhs.
Point AffineTransform.operator *(AffineTransform t, Point p)
[DebuggerStepThrough]
public static Point operator *(AffineTransform t, Point p);
Applies this transform to a Xui.Core.Math2D.Point, including translation.
This operation applies the full affine matrix, including scale, rotation, shear, and translation. Use this when transforming coordinates in space (e.g., an element's position).
t— The affine transform.p— The point to transform.
Returns: A new Xui.Core.Math2D.Point with the transform applied.
Vector AffineTransform.operator *(AffineTransform t, Vector v)
[DebuggerStepThrough]
public static Vector operator *(AffineTransform t, Vector v);
Applies only the linear portion (scale, rotation, shear) of this transform to a Xui.Core.Math2D.Vector.
Translation is not applied. Use this to transform directions, movement deltas, or normals.
t— The affine transform.v— The vector to transform.
Returns: A new Xui.Core.Math2D.Vector with the linear transform applied.
class Constants
Common mathematical constants used throughout 2D geometry and curve computations.
public static class Constants
{
public static readonly nfloat π;
public static readonly nfloat τ;
public static readonly nfloat ε;
public static readonly nfloat sqrt2;
public static readonly nfloat ϕ;
}
NFloat Constants.sqrt2
public static readonly nfloat sqrt2;
√2 (square root of 2): Diagonal of a unit square.
NFloat Constants.ε
public static readonly nfloat ε;
ε (epsilon): A small value used for numerical stability checks.
NFloat Constants.π
public static readonly nfloat π;
π (pi): Ratio of a circle’s circumference to its diameter.
NFloat Constants.τ
public static readonly nfloat τ;
τ (tau): One full circle in radians (2π).
NFloat Constants.ϕ
public static readonly nfloat ϕ;
ϕ (phi): The golden ratio (≈ 1.618).
struct Frame
Represents thickness values for each edge of a rectangular element.
A Xui.Core.Math2D.Frame defines spacing from the left, top, right, and bottom edges. It is typically used for layout constructs such as Margin, Padding, or BorderWidth. Unlike Xui.Core.Math2D.Rect, it does not represent position or size—only edge offsets.
public struct Frame
{
public nfloat Top;
public nfloat Right;
public nfloat Bottom;
public nfloat Left;
public bool IsUniform { get; }
public readonly bool IsZero { get; }
public nfloat TotalWidth { get; }
public nfloat TotalHeight { get; }
public static readonly Frame Zero;
[DebuggerStepThrough]
public Frame();
[DebuggerStepThrough]
public Frame(nfloat top, nfloat right, nfloat bottom, nfloat left);
[DebuggerStepThrough]
public static implicit operator Frame((nfloat top, nfloat right, nfloat bottom, nfloat left) value);
[DebuggerStepThrough]
public static implicit operator Frame((nfloat vertical, nfloat horizontal) value);
[DebuggerStepThrough]
public static implicit operator Frame(nfloat value);
[DebuggerStepThrough]
public static implicit operator Frame(int value);
[DebuggerStepThrough]
public static implicit operator Frame(double value);
[DebuggerStepThrough]
public static implicit operator Frame(float value);
[DebuggerStepThrough]
public static Frame operator *(Frame lhs, nfloat rhs);
[DebuggerStepThrough]
public static Frame operator +(Frame lhs, Frame rhs);
[DebuggerStepThrough]
public static Frame operator -(Frame lhs, Frame rhs);
[DebuggerStepThrough]
public static Frame Max(Frame lhs, Frame rhs);
[DebuggerStepThrough]
public static Frame Min(Frame lhs, Frame rhs);
[DebuggerStepThrough]
public override string ToString();
public static bool operator ==(Frame left, Frame right);
public static bool operator !=(Frame lhs, Frame rhs);
public override bool Equals(object? obj);
public override int GetHashCode();
}
Frame.Frame()
[DebuggerStepThrough]
public Frame();
Initializes a new Xui.Core.Math2D.Frame with all edges set to zero.
Frame.Frame(NFloat top, NFloat right, NFloat bottom, NFloat left)
[DebuggerStepThrough]
public Frame(nfloat top, nfloat right, nfloat bottom, nfloat left);
Initializes a new Xui.Core.Math2D.Frame with the specified edge thicknesses.
top— Top edge thickness.right— Right edge thickness.bottom— Bottom edge thickness.left— Left edge thickness.
NFloat Frame.Bottom
public nfloat Bottom;
The thickness of the bottom edge.
bool Frame.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.
int Frame.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.
bool Frame.IsUniform
public bool IsUniform { get; }
Returns true if all four edges have equal thickness.
readonly bool Frame.IsZero
public readonly bool IsZero { get; }
Returns true if all sides (Left, Top, Right, Bottom) are zero.
NFloat Frame.Left
public nfloat Left;
The thickness of the left edge.
Frame Frame.Max(Frame lhs, Frame rhs)
[DebuggerStepThrough]
public static Frame Max(Frame lhs, Frame rhs);
Returns a frame containing the maximum value for each edge from two frames.
Frame Frame.Min(Frame lhs, Frame rhs)
[DebuggerStepThrough]
public static Frame Min(Frame lhs, Frame rhs);
Returns a frame containing the minimum value for each edge from two frames.
NFloat Frame.Right
public nfloat Right;
The thickness of the right edge.
string Frame.ToString()
[DebuggerStepThrough]
public override string ToString();
Returns the fully qualified type name of this instance.
Returns: The fully qualified type name.
NFloat Frame.Top
public nfloat Top;
The thickness of the top edge.
NFloat Frame.TotalHeight
public nfloat TotalHeight { get; }
Gets the total vertical edge thickness (top + bottom).
NFloat Frame.TotalWidth
public nfloat TotalWidth { get; }
Gets the total horizontal edge thickness (left + right).
Frame Frame.Zero
public static readonly Frame Zero;
A frame with all edge values set to zero.
Frame Frame.operator +(Frame lhs, Frame rhs)
[DebuggerStepThrough]
public static Frame operator +(Frame lhs, Frame rhs);
Adds the corresponding edge thicknesses of two frames.
bool Frame.operator ==(Frame left, Frame right)
public static bool operator ==(Frame left, Frame right);
Returns true if all edge values match exactly.
Frame.implicit operator Frame(double value)
[DebuggerStepThrough]
public static implicit operator Frame(double value);
Implicitly converts a System.Double to a Xui.Core.Math2D.Frame, applying the same value to all four sides (Left, Top, Right, Bottom).
value— The double value to apply uniformly to all sides.
Returns: A Xui.Core.Math2D.Frame with all sides set to value.
Frame.implicit operator Frame(int value)
[DebuggerStepThrough]
public static implicit operator Frame(int value);
Implicitly converts an System.Int32 to a Xui.Core.Math2D.Frame, applying the same value to all four sides (Left, Top, Right, Bottom).
value— The integer value to apply uniformly to all sides.
Returns: A Xui.Core.Math2D.Frame with all sides set to value.
Frame.implicit operator Frame(NFloat value)
[DebuggerStepThrough]
public static implicit operator Frame(nfloat value);
Converts a scalar value into a uniform Xui.Core.Math2D.Frame for all sides.
Frame.implicit operator Frame(float value)
[DebuggerStepThrough]
public static implicit operator Frame(float value);
Implicitly converts a System.Single to a Xui.Core.Math2D.Frame, applying the same value to all four sides (Left, Top, Right, Bottom).
value— The float value to apply uniformly to all sides.
Returns: A Xui.Core.Math2D.Frame with all sides set to value.
Frame.implicit operator Frame((NFloat top, NFloat right, NFloat bottom, NFloat left) value)
[DebuggerStepThrough]
public static implicit operator Frame((nfloat top, nfloat right, nfloat bottom, nfloat left) value);
Converts a 4-tuple (top, right, bottom, left) to a Xui.Core.Math2D.Frame.
Frame.implicit operator Frame((NFloat vertical, NFloat horizontal) value)
[DebuggerStepThrough]
public static implicit operator Frame((nfloat vertical, nfloat horizontal) value);
Converts a 2-tuple (horizontal, vertical) to a Xui.Core.Math2D.Frame. Horizontal is applied to left and right; vertical to top and bottom.
bool Frame.operator !=(Frame lhs, Frame rhs)
public static bool operator !=(Frame lhs, Frame rhs);
Returns true if any edge value differs.
Frame Frame.operator *(Frame lhs, NFloat rhs)
[DebuggerStepThrough]
public static Frame operator *(Frame lhs, nfloat rhs);
Scales all edges of the frame by the specified scalar.
Frame Frame.operator -(Frame lhs, Frame rhs)
[DebuggerStepThrough]
public static Frame operator -(Frame lhs, Frame rhs);
Subtracts the corresponding edge thicknesses of two frames.
struct Point
Represents a point in 2D space, defined by its Xui.Core.Math2D.Point.X and Xui.Core.Math2D.Point.Y coordinates.
public struct Point
{
public nfloat X;
public nfloat Y;
public static readonly Point Zero;
public static readonly Point One;
[DebuggerStepThrough]
public Point(nfloat x, nfloat y);
[DebuggerStepThrough]
public static Point Lerp(Point start, Point end, nfloat step);
[DebuggerStepThrough]
public static nfloat Distance(Point a, Point b);
[DebuggerStepThrough]
public static nfloat SquaredDistance(Point a, Point b);
[DebuggerStepThrough]
public static nfloat TaxicabDistance(Point a, Point b);
[DebuggerStepThrough]
public static Vector operator -(Point lhs, Point rhs);
[DebuggerStepThrough]
public static Point operator +(Point lhs, Vector rhs);
[DebuggerStepThrough]
public static Point operator -(Point lhs, Vector rhs);
[DebuggerStepThrough]
public static implicit operator Point(ValueTuple<nfloat, nfloat> tuple);
[DebuggerStepThrough]
public static explicit operator Point(Vector vector);
[DebuggerStepThrough]
public static bool operator ==(Point lhs, Point rhs);
[DebuggerStepThrough]
public static bool operator !=(Point lhs, Point rhs);
[DebuggerStepThrough]
public static Point operator *(Point v, nfloat f);
public override string ToString();
public override bool Equals(object? obj);
public bool Equals(Point other);
public override int GetHashCode();
}
Point.Point(NFloat x, NFloat y)
[DebuggerStepThrough]
public Point(nfloat x, nfloat y);
Initializes a new point with the specified coordinates.
NFloat Point.Distance(Point a, Point b)
[DebuggerStepThrough]
public static nfloat Distance(Point a, Point b);
Returns the Euclidean distance between two points.
bool Point.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 Point.Equals(Point other)
public bool Equals(Point other);
Returns true if this point has the same coordinates as another.
int Point.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.
Point Point.Lerp(Point start, Point end, NFloat step)
[DebuggerStepThrough]
public static Point Lerp(Point start, Point end, nfloat step);
Linearly interpolates between two points by step.
start— The start point.end— The end point.step— A value from 0 to 1 indicating the interpolation position.
Point Point.One
public static readonly Point One;
A point at (1, 1), useful for normalized coordinates or vector math.
NFloat Point.SquaredDistance(Point a, Point b)
[DebuggerStepThrough]
public static nfloat SquaredDistance(Point a, Point b);
Returns the squared Euclidean distance between two points (no square root). Useful for performance comparisons or ordering by proximity.
NFloat Point.TaxicabDistance(Point a, Point b)
[DebuggerStepThrough]
public static nfloat TaxicabDistance(Point a, Point b);
Returns the Manhattan (taxicab) distance between two points.
The sum of the absolute horizontal and vertical distances. Often used in grid-based or discrete movement systems.
string Point.ToString()
public override string ToString();
Returns the fully qualified type name of this instance.
Returns: The fully qualified type name.
NFloat Point.X
public nfloat X;
The X-coordinate of the point.
NFloat Point.Y
public nfloat Y;
The Y-coordinate of the point.
Point Point.Zero
public static readonly Point Zero;
A point at the origin (0, 0).
Point Point.operator +(Point lhs, Vector rhs)
[DebuggerStepThrough]
public static Point operator +(Point lhs, Vector rhs);
Offsets a point by a vector.
bool Point.operator ==(Point lhs, Point rhs)
[DebuggerStepThrough]
public static bool operator ==(Point lhs, Point rhs);
Determines whether two points have equal coordinates.
Point.explicit operator Point(Vector vector)
[DebuggerStepThrough]
public static explicit operator Point(Vector vector);
Explicitly converts a vector to a point (drops directional semantics).
Point.implicit operator Point((NFloat, NFloat) tuple)
[DebuggerStepThrough]
public static implicit operator Point(ValueTuple<nfloat, nfloat> tuple);
Converts a tuple to a point.
bool Point.operator !=(Point lhs, Point rhs)
[DebuggerStepThrough]
public static bool operator !=(Point lhs, Point rhs);
Determines whether two points differ in any coordinate.
Point Point.operator *(Point v, NFloat f)
[DebuggerStepThrough]
public static Point operator *(Point v, nfloat f);
Apply an uniform scale to a point.
Vector Point.operator -(Point lhs, Point rhs)
[DebuggerStepThrough]
public static Vector operator -(Point lhs, Point rhs);
Returns the vector difference from one point to another.
Point Point.operator -(Point lhs, Vector rhs)
[DebuggerStepThrough]
public static Point operator -(Point lhs, Vector rhs);
Subtracts a vector from a point, offsetting it in the opposite direction.
struct Rect
Represents a rectangle in 2D space, defined by its origin (Xui.Core.Math2D.Rect.X, Xui.Core.Math2D.Rect.Y) and its dimensions (Xui.Core.Math2D.Rect.Width, Xui.Core.Math2D.Rect.Height).
Unlike Xui.Core.Math2D.Frame, which represents edge thicknesses around a box, Xui.Core.Math2D.Rect defines a positioned, sized area used for layout and rendering.
public struct Rect : INonEnumerableSet<Point>, IEquatable<Rect>
{
public nfloat X;
public nfloat Y;
public nfloat Width;
public nfloat Height;
[DebuggerStepThrough]
public Rect(nfloat x, nfloat y, nfloat width, nfloat height);
[DebuggerStepThrough]
public Rect(Point topLeft, Size size);
[DebuggerStepThrough]
public Rect(Vector topLeft, Size size);
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Point TopLeft { get; }
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Point TopCenter { get; }
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Point TopRight { get; }
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Point BottomRight { get; }
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Point BottomLeft { get; }
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public nfloat Left { get; }
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public nfloat Top { get; }
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public nfloat Right { get; }
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public nfloat Bottom { get; }
public Point Center { get; }
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Size Size { get; set; }
[DebuggerStepThrough]
public Rect Inset(nfloat inset);
[DebuggerStepThrough]
public bool Contains(Point point);
[DebuggerStepThrough]
public bool Intersects(Rect other);
[DebuggerStepThrough]
public Rect Expand(nfloat h, nfloat v);
[DebuggerStepThrough]
public Rect Expand(nfloat expand);
[DebuggerStepThrough]
public static implicit operator Rect(ValueTuple<nfloat, nfloat, nfloat, nfloat> tuple);
[DebuggerStepThrough]
public static Rect operator +(Rect rect, Frame frame);
[DebuggerStepThrough]
public static Rect operator -(Rect rect, Frame frame);
[DebuggerStepThrough]
public static bool operator ==(Rect lhs, Rect rhs);
[DebuggerStepThrough]
public static bool operator !=(Rect lhs, Rect rhs);
public override bool Equals(object? obj);
public bool Equals(Rect other);
public override int GetHashCode();
[DebuggerStepThrough]
public override string ToString();
}
Rect.Rect(NFloat x, NFloat y, NFloat width, NFloat height)
[DebuggerStepThrough]
public Rect(nfloat x, nfloat y, nfloat width, nfloat height);
Creates a new Xui.Core.Math2D.Rect from position and size.
Rect.Rect(Point topLeft, Size size)
[DebuggerStepThrough]
public Rect(Point topLeft, Size size);
Creates a new Xui.Core.Math2D.Rect from a top-left point and a size.
Rect.Rect(Vector topLeft, Size size)
[DebuggerStepThrough]
public Rect(Vector topLeft, Size size);
Creates a new Xui.Core.Math2D.Rect from a top-left vector and a size.
NFloat Rect.Bottom
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public nfloat Bottom { get; }
Returns the Y-coordinate of the bottom edge.
Point Rect.BottomLeft
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Point BottomLeft { get; }
Returns the bottom-left point of the rectangle.
Point Rect.BottomRight
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Point BottomRight { get; }
Returns the bottom-right point of the rectangle.
Point Rect.Center
public Point Center { get; }
Returns the center point of the rectangle.
bool Rect.Contains(Point point)
[DebuggerStepThrough]
public bool Contains(Point point);
Returns true if the specified point lies within this rectangle.
bool Rect.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 Rect.Equals(Rect other)
public bool Equals(Rect other);
Returns true if this rectangle is equal to another rectangle in position and size.
Rect Rect.Expand(NFloat expand)
[DebuggerStepThrough]
public Rect Expand(nfloat expand);
Returns a rectangle expanded uniformly in all directions.
Rect Rect.Expand(NFloat h, NFloat v)
[DebuggerStepThrough]
public Rect Expand(nfloat h, nfloat v);
Returns a rectangle expanded horizontally and vertically by the specified amounts.
int Rect.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.
NFloat Rect.Height
public nfloat Height;
The height of the rectangle.
Rect Rect.Inset(NFloat inset)
[DebuggerStepThrough]
public Rect Inset(nfloat inset);
Returns a new rectangle that is inset by the same amount on all four sides.
bool Rect.Intersects(Rect other)
[DebuggerStepThrough]
public bool Intersects(Rect other);
Returns whether this rectangle overlaps or touches other.
NFloat Rect.Left
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public nfloat Left { get; }
Returns the X-coordinate of the left edge.
NFloat Rect.Right
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public nfloat Right { get; }
Returns the X-coordinate of the right edge.
Size Rect.Size
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Size Size { get; set; }
Gets or sets the size of the rectangle.
string Rect.ToString()
[DebuggerStepThrough]
public override string ToString();
Returns the fully qualified type name of this instance.
Returns: The fully qualified type name.
NFloat Rect.Top
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public nfloat Top { get; }
Returns the Y-coordinate of the top edge.
Point Rect.TopCenter
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Point TopCenter { get; }
Returns the top-center point of the rectangle.
Point Rect.TopLeft
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Point TopLeft { get; }
Returns the top-left point of the rectangle.
Point Rect.TopRight
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
public Point TopRight { get; }
Returns the top-right point of the rectangle.
NFloat Rect.Width
public nfloat Width;
The width of the rectangle.
NFloat Rect.X
public nfloat X;
The X-coordinate of the rectangle’s top-left corner.
NFloat Rect.Y
public nfloat Y;
The Y-coordinate of the rectangle’s top-left corner.
Rect Rect.operator +(Rect rect, Frame frame)
[DebuggerStepThrough]
public static Rect operator +(Rect rect, Frame frame);
Returns a rectangle expanded outward by a Xui.Core.Math2D.Frame.
bool Rect.operator ==(Rect lhs, Rect rhs)
[DebuggerStepThrough]
public static bool operator ==(Rect lhs, Rect rhs);
Returns true if two rectangles are equal in position and size.
Rect.implicit operator Rect((NFloat, NFloat, NFloat, NFloat) tuple)
[DebuggerStepThrough]
public static implicit operator Rect(ValueTuple<nfloat, nfloat, nfloat, nfloat> tuple);
Implicit conversion from a 4-tuple to a rectangle.
bool Rect.operator !=(Rect lhs, Rect rhs)
[DebuggerStepThrough]
public static bool operator !=(Rect lhs, Rect rhs);
Returns true if any of the rectangle fields are different.
Rect Rect.operator -(Rect rect, Frame frame)
[DebuggerStepThrough]
public static Rect operator -(Rect rect, Frame frame);
Returns a rectangle inset inward by a Xui.Core.Math2D.Frame.
struct Size
Represents a two-dimensional size with Xui.Core.Math2D.Size.Width and Xui.Core.Math2D.Size.Height components.
A Xui.Core.Math2D.Size specifies how much space an element occupies, without defining its position. It is commonly used in layout systems to describe constraints or measured results.
public struct Size
{
public nfloat Width;
public nfloat Height;
public static readonly Size Empty;
public static readonly Size Infinity;
[DebuggerStepThrough]
public Size();
[DebuggerStepThrough]
public Size(nfloat width, nfloat height);
[DebuggerStepThrough]
public static implicit operator Size(ValueTuple<nfloat, nfloat> tuple);
public static implicit operator Size(int uniform);
[DebuggerStepThrough]
public static explicit operator Size(Vector vector);
[DebuggerStepThrough]
public static Size operator +(Size size, Frame frame);
[DebuggerStepThrough]
public static Size operator -(Size size, Frame frame);
[DebuggerStepThrough]
public static Size operator +(Size lhs, Size rhs);
[DebuggerStepThrough]
public override string ToString();
[DebuggerStepThrough]
public static bool operator ==(Size lhs, Size rhs);
[DebuggerStepThrough]
public static bool operator !=(Size lhs, Size rhs);
[DebuggerStepThrough]
public override bool Equals(object? obj);
public bool Equals(Size other);
[DebuggerStepThrough]
public override int GetHashCode();
public static Size Min(Size lhs, Size rhs);
public static Size Max(Size lhs, Size rhs);
}
Size.Size()
[DebuggerStepThrough]
public Size();
Initializes a new instance of the Xui.Core.Math2D.Size struct with zero dimensions.
Size.Size(NFloat width, NFloat height)
[DebuggerStepThrough]
public Size(nfloat width, nfloat height);
Initializes a new instance of the Xui.Core.Math2D.Size struct with the given width and height.
width— The width of the size.height— The height of the size.
Size Size.Empty
public static readonly Size Empty;
A size with zero width and height.
bool Size.Equals(object? obj)
[DebuggerStepThrough]
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 Size.Equals(Size other)
public bool Equals(Size other);
Returns true if this size is equal to the specified other.
int Size.GetHashCode()
[DebuggerStepThrough]
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.
NFloat Size.Height
public nfloat Height;
The height of the element.
Size Size.Infinity
public static readonly Size Infinity;
A size with infinite width and height.
Size Size.Max(Size lhs, Size rhs)
public static Size Max(Size lhs, Size rhs);
Returns the maximum of two sizes, using the larger width and height from each.
Size Size.Min(Size lhs, Size rhs)
public static Size Min(Size lhs, Size rhs);
Returns the minimum of two sizes, using the smaller width and height from each.
string Size.ToString()
[DebuggerStepThrough]
public override string ToString();
Returns the fully qualified type name of this instance.
Returns: The fully qualified type name.
NFloat Size.Width
public nfloat Width;
The width of the element.
Size Size.operator +(Size size, Frame frame)
[DebuggerStepThrough]
public static Size operator +(Size size, Frame frame);
Adds edge spacing from a Xui.Core.Math2D.Frame to a Xui.Core.Math2D.Size, increasing its dimensions.
Size Size.operator +(Size lhs, Size rhs)
[DebuggerStepThrough]
public static Size operator +(Size lhs, Size rhs);
Adds two sizes together component-wise.
bool Size.operator ==(Size lhs, Size rhs)
[DebuggerStepThrough]
public static bool operator ==(Size lhs, Size rhs);
Returns true if the two sizes have the same dimensions.
Size.explicit operator Size(Vector vector)
[DebuggerStepThrough]
public static explicit operator Size(Vector vector);
Explicitly converts a Xui.Core.Math2D.Vector to a Xui.Core.Math2D.Size.
Size.implicit operator Size(int uniform)
public static implicit operator Size(int uniform);
Returns the size of a square.
Size.implicit operator Size((NFloat, NFloat) tuple)
[DebuggerStepThrough]
public static implicit operator Size(ValueTuple<nfloat, nfloat> tuple);
Implicitly converts a tuple to a Xui.Core.Math2D.Size.
bool Size.operator !=(Size lhs, Size rhs)
[DebuggerStepThrough]
public static bool operator !=(Size lhs, Size rhs);
Returns true if the two sizes have different dimensions.
Size Size.operator -(Size size, Frame frame)
[DebuggerStepThrough]
public static Size operator -(Size size, Frame frame);
Subtracts edge spacing from a Xui.Core.Math2D.Size, reducing its dimensions.
struct Vector
Represents a 2D vector with X and Y components, commonly used for geometric operations, layout math, and movement in 2D space.
public struct Vector
{
public nfloat X;
public nfloat Y;
[DebuggerStepThrough]
public Vector(nfloat x, nfloat y);
public static readonly Vector Zero;
public static readonly Vector One;
public static readonly Vector Left;
public static readonly Vector Up;
public static readonly Vector Right;
public static readonly Vector Down;
public Vector Normalized { get; }
public Vector PerpendicularCCW { get; }
public Vector PerpendicularCW { get; }
public nfloat Magnitude { get; }
public nfloat Length { get; }
public nfloat MagnitudeSquared { get; }
public nfloat ArcAngle { get; }
public Vector Rotate(nfloat degrees);
[DebuggerStepThrough]
public static nfloat Dot(Vector lhs, Vector rhs);
[DebuggerStepThrough]
public static Vector Project(Vector lhs, Vector rhs);
[DebuggerStepThrough]
public static nfloat Cross(Vector lhs, Vector rhs);
[DebuggerStepThrough]
public Vector Clamp(nfloat max);
[DebuggerStepThrough]
public static nfloat Angle(Vector v);
[DebuggerStepThrough]
public static Vector Angle(nfloat radians);
[DebuggerStepThrough]
public static nfloat Angle(Vector lhs, Vector rhs);
[DebuggerStepThrough]
public static Vector Lerp(Vector start, Vector end, nfloat step);
[DebuggerStepThrough]
public static implicit operator Vector(Point point);
[DebuggerStepThrough]
public static Vector operator *(Vector v, nfloat f);
[DebuggerStepThrough]
public static Vector operator /(Vector v, nfloat f);
[DebuggerStepThrough]
public static Vector operator *(nfloat f, Vector v);
[DebuggerStepThrough]
public static Vector operator +(Vector lhs, Vector rhs);
[DebuggerStepThrough]
public static Vector operator -(Vector lhs, Vector rhs);
[DebuggerStepThrough]
public static implicit operator Vector(ValueTuple<nfloat, nfloat> tuple);
[DebuggerStepThrough]
public static bool operator ==(Vector lhs, Vector rhs);
[DebuggerStepThrough]
public static bool operator !=(Vector lhs, Vector rhs);
public override bool Equals(object? obj);
public bool Equals(Vector other);
public override int GetHashCode();
public override string ToString();
}
Vector.Vector(NFloat x, NFloat y)
[DebuggerStepThrough]
public Vector(nfloat x, nfloat y);
Initializes a new instance of the Xui.Core.Math2D.Vector struct with the specified X and Y components.
x— The horizontal component of the vector.y— The vertical component of the vector.
Vector Vector.Angle(NFloat radians)
[DebuggerStepThrough]
public static Vector Angle(nfloat radians);
Returns a unit vector rotated clockwise from the upward direction (0, 1) by the given angle (in radians).
NFloat Vector.Angle(Vector v)
[DebuggerStepThrough]
public static nfloat Angle(Vector v);
Returns the clockwise angle (in radians) from the upward direction (0, 1) to the given vector.
NFloat Vector.Angle(Vector lhs, Vector rhs)
[DebuggerStepThrough]
public static nfloat Angle(Vector lhs, Vector rhs);
Returns the signed angle (in radians) from lhs to rhs, clockwise from upward.
NFloat Vector.ArcAngle
public nfloat ArcAngle { get; }
Gets the angle in radians between the vector and the positive X-axis, measured counter-clockwise in the range [-π, π].
This is equivalent to calling Atan2(Y, X) and is commonly used to compute polar angles from directional vectors, such as when determining the angular position of a point on a circle or ellipse.
Returns: The angle in radians between this vector and the X-axis.
Vector Vector.Clamp(NFloat max)
[DebuggerStepThrough]
public Vector Clamp(nfloat max);
Returns a new vector with its magnitude limited to the specified maximum.
NFloat Vector.Cross(Vector lhs, Vector rhs)
[DebuggerStepThrough]
public static nfloat Cross(Vector lhs, Vector rhs);
Returns the 2D cross product (scalar) of two vectors.
NFloat Vector.Dot(Vector lhs, Vector rhs)
[DebuggerStepThrough]
public static nfloat Dot(Vector lhs, Vector rhs);
Returns the dot product of two vectors.
Vector Vector.Down
public static readonly Vector Down;
A unit vector pointing down (0, 1).
bool Vector.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 Vector.Equals(Vector other)
public bool Equals(Vector other);
Returns true if this vector is equal to another vector.
int Vector.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.
Vector Vector.Left
public static readonly Vector Left;
A unit vector pointing left (-1, 0).
NFloat Vector.Length
public nfloat Length { get; }
Returns the magnitude (length) of the vector.
Vector Vector.Lerp(Vector start, Vector end, NFloat step)
[DebuggerStepThrough]
public static Vector Lerp(Vector start, Vector end, nfloat step);
Linearly interpolates between two vectors by step.
NFloat Vector.Magnitude
public nfloat Magnitude { get; }
Returns the magnitude (length) of the vector.
NFloat Vector.MagnitudeSquared
public nfloat MagnitudeSquared { get; }
Returns the squared magnitude (length squared) of the vector. This avoids the square root computation used in Xui.Core.Math2D.Vector.Magnitude.
Vector Vector.Normalized
public Vector Normalized { get; }
Returns a normalized (unit length) version of this vector.
Vector Vector.One
public static readonly Vector One;
A unit vector (1, 1).
Vector Vector.PerpendicularCCW
public Vector PerpendicularCCW { get; }
Returns the vector rotated 90° counter-clockwise (CCW).
Vector Vector.PerpendicularCW
public Vector PerpendicularCW { get; }
Returns the vector rotated 90° clockwise (CW).
Vector Vector.Project(Vector lhs, Vector rhs)
[DebuggerStepThrough]
public static Vector Project(Vector lhs, Vector rhs);
Projects lhs onto rhs.
Vector Vector.Right
public static readonly Vector Right;
A unit vector pointing right (1, 0).
Vector Vector.Rotate(NFloat degrees)
public Vector Rotate(nfloat degrees);
Rotates the vector counterclockwise by the given angle (in degrees).
string Vector.ToString()
public override string ToString();
Returns the fully qualified type name of this instance.
Returns: The fully qualified type name.
Vector Vector.Up
public static readonly Vector Up;
A unit vector pointing up (0, -1).
NFloat Vector.X
public nfloat X;
The horizontal component of the vector.
NFloat Vector.Y
public nfloat Y;
The vertical component of the vector.
Vector Vector.Zero
public static readonly Vector Zero;
A zero vector (0, 0).
Vector Vector.operator +(Vector lhs, Vector rhs)
[DebuggerStepThrough]
public static Vector operator +(Vector lhs, Vector rhs);
Adds two vectors.
Vector Vector.operator /(Vector v, NFloat f)
[DebuggerStepThrough]
public static Vector operator /(Vector v, nfloat f);
Divides a vector by a scalar.
bool Vector.operator ==(Vector lhs, Vector rhs)
[DebuggerStepThrough]
public static bool operator ==(Vector lhs, Vector rhs);
Returns true if the two vectors have equal components.
Vector.implicit operator Vector((NFloat, NFloat) tuple)
[DebuggerStepThrough]
public static implicit operator Vector(ValueTuple<nfloat, nfloat> tuple);
Implicitly converts a tuple to a Xui.Core.Math2D.Vector.
Vector.implicit operator Vector(Point point)
[DebuggerStepThrough]
public static implicit operator Vector(Point point);
Implicitly converts a Xui.Core.Math2D.Point to a Xui.Core.Math2D.Vector.
bool Vector.operator !=(Vector lhs, Vector rhs)
[DebuggerStepThrough]
public static bool operator !=(Vector lhs, Vector rhs);
Returns true if any component of the two vectors is different.
Vector Vector.operator *(NFloat f, Vector v)
[DebuggerStepThrough]
public static Vector operator *(nfloat f, Vector v);
Multiplies a scalar by a vector.
Vector Vector.operator *(Vector v, NFloat f)
[DebuggerStepThrough]
public static Vector operator *(Vector v, nfloat f);
Multiplies a vector by a scalar.
Vector Vector.operator -(Vector lhs, Vector rhs)
[DebuggerStepThrough]
public static Vector operator -(Vector lhs, Vector rhs);
Subtracts one vector from another.