Show / Hide Table of Contents

Class MathHelpers

Static class consisting of mathematical "helper" functions and constants that can be useful for performing operations on a 2D grid.

Inheritance
object
MathHelpers
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: SadRogue.Primitives
Assembly: TheSadRogue.Primitives.dll
Syntax
public static class MathHelpers

Fields

View Source

DegreePctOfCircle

Result of 1/360; represents in decimal form a percent of a circle that a degree constitutes.

Declaration
public const double DegreePctOfCircle = 0.002777777777777778
Field Value
Type Description
double
View Source

DegreesToRadiansConstant

Pi / 180. Used to speed up calculations related to circles.

Declaration
public const double DegreesToRadiansConstant = 0.017453292519943295
Field Value
Type Description
double
View Source

RadiansToDegreesConstant

180 / Pi. Used to speed up calculations related to circles.

Declaration
public const double RadiansToDegreesConstant = 57.29577951308232
Field Value
Type Description
double

Methods

View Source

Clamp(double, double, double)

Restricts a value to a specified range.

Declaration
public static double Clamp(double value, double min, double max)
Parameters
Type Name Description
double value

The value to restrict.

double min

The minimum to clamp the value to.

double max

The maximum to clamp the value to.

Returns
Type Description
double

The clamped value.

View Source

Clamp(int, int, int)

Restricts a value to a specified range.

Declaration
public static int Clamp(int value, int min, int max)
Parameters
Type Name Description
int value

The value to restrict.

int min

The minimum to clamp the value to.

int max

The maximum to clamp the value to.

Returns
Type Description
int

The clamped value.

View Source

Clamp(float, float, float)

Restricts a value to a specified range.

Declaration
public static float Clamp(float value, float min, float max)
Parameters
Type Name Description
float value

The value to restrict.

float min

The minimum to clamp the value to.

float max

The maximum to clamp the value to.

Returns
Type Description
float

The clamped value.

View Source

Lerp(double, double, double)

Performs linear interpolation between two values.

Declaration
public static double Lerp(double value1, double value2, double amount)
Parameters
Type Name Description
double value1

Starting value.

double value2

Ending value.

double amount

The weight to apply to value2.

Returns
Type Description
double

The interpolated value between value1 and value2.

View Source

Lerp(float, float, float)

Performs linear interpolation between two values.

Declaration
public static float Lerp(float value1, float value2, float amount)
Parameters
Type Name Description
float value1

Starting value.

float value2

Ending value.

float amount

The weight to apply to value2.

Returns
Type Description
float

The interpolated value between value1 and value2.

View Source

ToDegree(double)

Converts given angle from radians to degrees.

Declaration
public static double ToDegree(double radAngle)
Parameters
Type Name Description
double radAngle

Angle in radians.

Returns
Type Description
double

The given angle in degrees.

View Source

ToRadian(double)

Converts given angle from degrees to radians.

Declaration
public static double ToRadian(double degAngle)
Parameters
Type Name Description
double degAngle

Angle in degrees.

Returns
Type Description
double

The given angle in radians.

View Source

Wrap(float, float, float)

Wraps a value around the min and max.

Declaration
public static float Wrap(float value, float min, float max)
Parameters
Type Name Description
float value

The value to wrap.

float min

The minimum value before it transforms into the maximum.

float max

The maximum value before it transforms into the minimum.

Returns
Type Description
float

A new value if it falls outside the min/max range otherwise, the same value.

  • View Source
In this article
Back to top Generated by DocFX