Table of Contents

Class Mathf

Namespace
BasilEngine.Mathematics
Assembly
BasilEngine.dll
[Disabled]
public static class Mathf
Inheritance
Mathf
Inherited Members

Properties

Deg2Rad

Conversion multiplier from degrees to radians.

public static float Deg2Rad { get; }

Property Value

float

Epsilon

Smallest positive non-zero value greater than zero.

public static float Epsilon { get; }

Property Value

float

Infinity

Represents positive infinity.

public static float Infinity { get; }

Property Value

float

NegativeInfinity

Represents negative infinity.

public static float NegativeInfinity { get; }

Property Value

float

PI

The constant value of pi.

public static float PI { get; }

Property Value

float

Rad2Deg

Conversion multiplier from radians to degrees.

public static float Rad2Deg { get; }

Property Value

float

Methods

Abs(float)

Gets the absolute value of a float.

public static float Abs(float f)

Parameters

f float

Input value.

Returns

float

Absolute value of the input.

Acos(float)

Calculates the arccosine of a value.

public static float Acos(float f)

Parameters

f float

Input value.

Returns

float

Angle in radians whose cosine is the input.

Approximately(float, float)

Determines whether two floats are approximately equal.

public static bool Approximately(float a, float b)

Parameters

a float

First value.

b float

Second value.

Returns

bool

True if the values are within a small epsilon.

Asin(float)

Calculates the arcsine of a value.

public static float Asin(float f)

Parameters

f float

Input value.

Returns

float

Angle in radians whose sine is the input.

Atan(float)

Calculates the arctangent of a value.

public static float Atan(float f)

Parameters

f float

Input value.

Returns

float

Angle in radians whose tangent is the input.

Atan2(float, float)

Calculates the angle whose tangent is the quotient of two numbers.

public static float Atan2(float y, float x)

Parameters

y float

Y component.

x float

X component.

Returns

float

Angle in radians between the positive X-axis and the point.

Ceil(float)

Returns the smallest integral value greater than or equal to the specified number.

public static float Ceil(float f)

Parameters

f float

Input value.

Returns

float

Ceiling of the input.

CeilToInt(float)

Returns the smallest integral value greater than or equal to the specified number as an int.

public static int CeilToInt(float f)

Parameters

f float

Input value.

Returns

int

Ceiling of the input as an int.

Clamp(int, int, int)

Clamps an int between a minimum and maximum value.

public static int Clamp(int value, int min, int max)

Parameters

value int

Input value.

min int

Minimum allowed value.

max int

Maximum allowed value.

Returns

int

Clamped value.

Clamp(float, float, float)

Clamps a float between a minimum and maximum value.

public static float Clamp(float value, float min, float max)

Parameters

value float

Input value.

min float

Minimum allowed value.

max float

Maximum allowed value.

Returns

float

Clamped value.

Clamp01(float)

Clamps a value between 0 and 1.

public static float Clamp01(float result)

Parameters

result float

Input value.

Returns

float

Value clamped to the [0,1] range.

ClosestPowerOfTwo(int)

Finds the closest power of two that is greater than or equal to the specified value.

public static int ClosestPowerOfTwo(int value)

Parameters

value int

Input value.

Returns

int

Next power of two.

CorrelatedColorTemperatureToRGB(float)

Converts a correlated color temperature in Kelvin to an RGB color.

public static Color CorrelatedColorTemperatureToRGB(float kelvin)

Parameters

kelvin float

Temperature in Kelvin.

Returns

Color

RGB color approximating the temperature.

Cos(float)

Calculates the cosine of an angle in radians.

public static float Cos(float radians)

Parameters

radians float

Angle in radians.

Returns

float

Cosine of the input angle.

DeltaAngle(float, float)

Calculates the shortest delta between two angles in degrees.

public static float DeltaAngle(float current, float target)

Parameters

current float

Current angle.

target float

Target angle.

Returns

float

Signed minimal angle difference.

Exp(float)

Returns e raised to the specified power.

public static float Exp(float power)

Parameters

power float

Exponent to raise e to.

Returns

float

Result of e^power.

FloatToHalf(float)

Converts a float into an unsigned 16-bit value representing the high 16 bits.

public static ushort FloatToHalf(float f)

Parameters

f float

Float to convert.

Returns

ushort

High 16 bits of the float.

Floor(float)

Returns the largest integer less than or equal to the specified value.

public static float Floor(float f)

Parameters

f float

Input value.

Returns

float

Floor of the input.

FloorToInt(float)

Returns the largest integer less than or equal to the specified value as an int.

public static int FloorToInt(float f)

Parameters

f float

Input value.

Returns

int

Floor of the input as an int.

GammaToLinearSpace(float)

Converts a value from gamma (sRGB) to linear space.

public static float GammaToLinearSpace(float f)

Parameters

f float

Gamma-space value.

Returns

float

Linear-space value.

HalfToFloat(ushort)

Converts the high 16 bits of an integer into a float.

public static float HalfToFloat(ushort val)

Parameters

val ushort

Half value.

Returns

float

Converted float.

InverseLerp(float, float, float)

Calculates the linear parameter that produces the interpolant value within the range [a, b].

public static float InverseLerp(float a, float b, float value)

Parameters

a float

Range start.

b float

Range end.

value float

Value within the range.

Returns

float

Normalized position between 0 and 1.

IsPowerOfTwo(int)

Determines if a value is a power of two.

public static bool IsPowerOfTwo(int value)

Parameters

value int

Input value.

Returns

bool

True if the value is a power of two.

Lerp(float, float, float)

Linearly interpolates between two values with clamping.

public static float Lerp(float a, float b, float t)

Parameters

a float

Start value.

b float

End value.

t float

Interpolation factor in [0,1].

Returns

float

Interpolated value.

LerpAngle(float, float, float)

Interpolates between two angles taking the shortest path.

public static float LerpAngle(float a, float b, float t)

Parameters

a float

Start angle in degrees.

b float

End angle in degrees.

t float

Interpolation factor in [0,1].

Returns

float

Interpolated angle in degrees.

LerpUnclamped(float, float, float)

Linearly interpolates between two values without clamping the interpolation factor.

public static float LerpUnclamped(float a, float b, float t)

Parameters

a float

Start value.

b float

End value.

t float

Interpolation factor.

Returns

float

Interpolated value.

LinearToGammaSpace(float)

Converts a value from linear space to gamma (sRGB) space.

public static float LinearToGammaSpace(float f)

Parameters

f float

Linear-space value.

Returns

float

Gamma-space value.

Log(float)

Natural logarithm of a specified value.

public static float Log(float f)

Parameters

f float

Input value.

Returns

float

Natural log of the input.

Log10(float)

Base-10 logarithm of a specified value.

public static float Log10(float f)

Parameters

f float

Input value.

Returns

float

Log base 10 of the input.

Max(float, float)

Returns the larger of two floating-point numbers.

public static float Max(float a, float b)

Parameters

a float
b float

Returns

float

Min(float, float)

Returns the smaller of two floating-point numbers.

public static float Min(float a, float b)

Parameters

a float
b float

Returns

float

MoveTowards(float, float, float)

Moves a value towards a target by a maximum change.

public static float MoveTowards(float current, float target, float maxDelta)

Parameters

current float

Current value.

target float

Target value.

maxDelta float

Maximum change allowed.

Returns

float

New value after applying the move.

MoveTowardsAngle(float, float, float)

Moves an angle towards a target angle by a maximum change, accounting for wraparound.

public static float MoveTowardsAngle(float current, float target, float maxDelta)

Parameters

current float
target float
maxDelta float

Returns

float

NextPowerOfTwo(int)

Returns the smallest power of two that is greater than or equal to the specified value.

public static float NextPowerOfTwo(int value)

Parameters

value int

Returns

float

PingPong(float, float)

Ping-pongs a value between 0 and length.

public static float PingPong(float t, float length)

Parameters

t float
length float

Returns

float

Pow(float, float)

Raises a number to a specified power.

public static float Pow(float f, float p)

Parameters

f float
p float

Returns

float

Repeat(float, float)

Repeats a value in the range [0, length).

public static float Repeat(float t, float length)

Parameters

t float
length float

Returns

float

Round(float)

Rounds a value to the nearest integer.

public static float Round(float f)

Parameters

f float

Returns

float

RoundToInt(float)

Rounds a value to the nearest integer and returns it as an int.

public static int RoundToInt(float f)

Parameters

f float

Returns

int

Sign(float)

Gets the sign of a value.

public static float Sign(float f)

Parameters

f float

Returns

float

Sin(float)

Calculates the sine of an angle in radians.

public static float Sin(float radians)

Parameters

radians float

Angle in radians.

Returns

float

Sine of the input angle.

SmoothDamp(float, float, ref float, float, float, float)

Smoothly damps a value towards a target using a critically damped spring function.

public static float SmoothDamp(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed, float deltaTime)

Parameters

current float
target float
currentVelocity float
smoothTime float
maxSpeed float
deltaTime float

Returns

float

SmoothDampAngle(float, float, ref float, float, float, float)

Smoothly damps an angle towards a target angle using a critically damped spring function.

public static float SmoothDampAngle(float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed, float deltaTime)

Parameters

current float
target float
currentVelocity float
smoothTime float
maxSpeed float
deltaTime float

Returns

float

SmoothStep(float, float, float)

Interpolates between two values using a smooth cubic curve.

public static float SmoothStep(float from, float to, float t)

Parameters

from float
to float
t float

Returns

float

Sqrt(float)

Returns the square root of a value.

public static float Sqrt(float f)

Parameters

f float

Returns

float

Tan(float)

Returns the tangent of the specified angle in radians.

public static float Tan(float f)

Parameters

f float

Returns

float