MathUtils

AUTO-GENERATED FILE – DO NOT EDIT MANUALLY

This page documents the supported public API surface only. Private, internal, benchmark, test, and implementation-detail types are intentionally omitted.

Declaration

1
public static class MathUtils

Summary

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.

Metadata

Namespace: GridPlacement.Core.Math

Source File: cs/Core/Math/MathUtils.cs

Assembly: GridPlacement.Core

Type: class

Methods

Clamp

1
2
3
4
5
public static int Clamp(
    int value,
    int min,
    int max
)

Clamps a value between min and max (inclusive).


Clamp

1
2
3
4
5
public static float Clamp(
    float value,
    float min,
    float max
)

Clamps a float value between min and max (inclusive).


Clamp

1
2
3
4
5
public static double Clamp(
    double value,
    double min,
    double max
)

Clamps a double value between min and max (inclusive).


Max

1
2
3
4
public static int Max(
    int a,
    int b
)

Returns the larger of two integers.


Max

1
2
3
4
public static float Max(
    float a,
    float b
)

Returns the larger of two floats.


Max

1
2
3
4
public static double Max(
    double a,
    double b
)

Returns the larger of two doubles.


Min

1
2
3
4
public static int Min(
    int a,
    int b
)

Returns the smaller of two integers.


Min

1
2
3
4
public static float Min(
    float a,
    float b
)

Returns the smaller of two floats.


Min

1
2
3
4
public static double Min(
    double a,
    double b
)

Returns the smaller of two doubles.


Lerp

1
2
3
4
5
public static float Lerp(
    float from,
    float to,
    float weight
)

Linear interpolation between two values.

Parameters

NameDescription
fromStart value
toEnd value
weightInterpolation weight (0-1)

Lerp

1
2
3
4
5
public static double Lerp(
    double from,
    double to,
    double weight
)

Linear interpolation between two double values.


InverseLerp

1
2
3
4
5
public static float InverseLerp(
    float from,
    float to,
    float value
)

Inverse linear interpolation - returns where a value falls between two points.

Parameters

NameDescription
fromStart value
toEnd value
valueThe value to find the position of

Returns

0 if value equals from, 1 if value equals to


Abs

1
public static int Abs(int value)

Returns the absolute value of an integer.


Abs

1
public static float Abs(float value)

Returns the absolute value of a float.


Sign

1
public static int Sign(int value)

Returns the sign of a number (-1, 0, or 1).


Sign

1
public static float Sign(float value)

Returns the sign of a float (-1, 0, or 1).


RoundToInt

1
public static int RoundToInt(float value)

Rounds a float to the nearest integer.


FloorToInt

1
public static int FloorToInt(float value)

Floors a float to the nearest integer.


CeilToInt

1
public static int CeilToInt(float value)

Ceils a float to the nearest integer.


Approximately

1
2
3
4
5
public static bool Approximately(
    float a,
    float b,
    float epsilon = 0.00001f
)

Checks if two floats are approximately equal within epsilon.


Wrap

1
2
3
4
public static int Wrap(
    int value,
    int length
)

Wraps a value to stay within a range [0, length).


Wrap

1
2
3
4
public static float Wrap(
    float value,
    float length
)

Wraps a float value to stay within a range [0, length).


Distance

1
2
3
4
5
6
public static float Distance(
    float x1,
    float y1,
    float x2,
    float y2
)

Calculates the distance between two points.


DistanceSquared

1
2
3
4
5
6
public static float DistanceSquared(
    float x1,
    float y1,
    float x2,
    float y2
)

Calculates the squared distance between two points (faster than Distance).


DegToRad

1
public static float DegToRad(float degrees)

Converts degrees to radians.


RadToDeg

1
public static float RadToDeg(float radians)

Converts radians to degrees.


SmoothStep

1
2
3
4
5
public static float SmoothStep(
    float from,
    float to,
    float weight
)

Smoothly interpolates between two values using cubic Hermite interpolation.


MoveToward

1
2
3
4
5
public static float MoveToward(
    float from,
    float to,
    float delta
)

Moves a value toward a target by a maximum delta.