Table of Contents

Class MathUtils

Namespace
ValveResourceFormat.Renderer
Assembly
Renderer.dll

Common math utility functions for rendering and animation.

public static class MathUtils

Inheritance

Inherited Members

Methods

Fract(float)

Returns the fractional part of a value (x - floor(x)).

public static float Fract(float x)

Parameters

x float

Returns

float

LerpAngle(float, float, float)

Linearly interpolates between two angles in radians, taking the shortest path around the circle.

public static float LerpAngle(float from, float to, float amount)

Parameters

from float

Start angle in radians.

to float

End angle in radians.

amount float

Interpolation weight (0.0 = from, 1.0 = to).

Returns

float

Interpolated angle in radians.

MinMaxFixUp<T>(ref T, ref T)

Swaps min and max if min > max.

public static void MinMaxFixUp<T>(ref T min, ref T max) where T : INumber<T>

Parameters

min T
max T

Type Parameters

T

Remap(float, float, float)

Remaps a value from input range to 0-1.

public static float Remap(float x, float inputMin, float inputMax)

Parameters

x float

Value to remap.

inputMin float

Input range minimum.

inputMax float

Input range maximum.

Returns

float

Value remapped to 0-1 range.

RemapRange(float, float, float, float, float)

Remaps a value from one range to another.

public static float RemapRange(float x, float inputMin, float inputMax, float outputMin, float outputMax)

Parameters

x float

Value to remap.

inputMin float

Input range minimum.

inputMax float

Input range maximum.

outputMin float

Output range minimum.

outputMax float

Output range maximum.

Returns

float

Value remapped to output range.

Saturate(float)

Clamps a value to [0, 1].

public static float Saturate(float x)

Parameters

x float

Returns

float

Wrap(float, float, float)

Wraps a value within a range (modulo with offset).

public static float Wrap(float x, float lowBounds, float highBounds)

Parameters

x float
lowBounds float
highBounds float

Returns

float