MathUtils
MathUtils
Pure C# math utilities to replace Godot’s Mathf class. Provides AOT-compatible math operations for iOS/Android. Shared-safe: stateless and thread-safe; safe to reuse across user scopes.
Project: GridPlacement v6.0
Layer: Godot
Source: Godot/Core/Math/MathUtils.cs
Namespace: GridBuilding.Core.Math
Kind: class
Parsing Method: AST-based (Roslyn) - NOT regex
⚠️ IMPORTANT: This documentation was generated using AST parsing, not regex.
Methods
Clamp
Clamps a value between min and max (inclusive).
Returns: int
Parameters:
int valueint minint max
Clamp
Clamps a float value between min and max (inclusive).
Returns: float
Parameters:
float valuefloat minfloat max
Clamp
Clamps a double value between min and max (inclusive).
Returns: double
Parameters:
double valuedouble mindouble max
Max
Returns the larger of two integers.
Returns: int
Parameters:
int aint b
Max
Returns the larger of two floats.
Returns: float
Parameters:
float afloat b
Max
Returns the larger of two doubles.
Returns: double
Parameters:
double adouble b
Min
Returns the smaller of two integers.
Returns: int
Parameters:
int aint b
Min
Returns the smaller of two floats.
Returns: float
Parameters:
float afloat b
Min
Returns the smaller of two doubles.
Returns: double
Parameters:
double adouble b
Lerp
Linear interpolation between two values.
Returns: float
Parameters:
float fromfloat tofloat weight
Lerp
Linear interpolation between two double values.
Returns: double
Parameters:
double fromdouble todouble weight
InverseLerp
Inverse linear interpolation - returns where a value falls between two points.
Returns: float
Parameters:
float fromfloat tofloat value
Abs
Returns the absolute value of an integer.
Returns: int
Parameters:
int value
Abs
Returns the absolute value of a float.
Returns: float
Parameters:
float value
Sign
Returns the sign of a number (-1, 0, or 1).
Returns: int
Parameters:
int value
Sign
Returns the sign of a float (-1, 0, or 1).
Returns: float
Parameters:
float value
RoundToInt
Rounds a float to the nearest integer.
Returns: int
Parameters:
float value
FloorToInt
Floors a float to the nearest integer.
Returns: int
Parameters:
float value
CeilToInt
Ceils a float to the nearest integer.
Returns: int
Parameters:
float value
Approximately
Checks if two floats are approximately equal within epsilon.
Returns: bool
Parameters:
float afloat bfloat epsilon
Wrap
Wraps a value to stay within a range [0, length).
Returns: int
Parameters:
int valueint length
Wrap
Wraps a float value to stay within a range [0, length).
Returns: float
Parameters:
float valuefloat length
Distance
Calculates the distance between two points.
Returns: float
Parameters:
float x1float y1float x2float y2
DistanceSquared
Calculates the squared distance between two points (faster than Distance).
Returns: float
Parameters:
float x1float y1float x2float y2
DegToRad
Converts degrees to radians.
Returns: float
Parameters:
float degrees
RadToDeg
Converts radians to degrees.
Returns: float
Parameters:
float radians
SmoothStep
Smoothly interpolates between two values using cubic Hermite interpolation.
Returns: float
Parameters:
float fromfloat tofloat weight
MoveToward
Moves a value toward a target by a maximum delta.
Returns: float
Parameters:
float fromfloat tofloat delta