C# Class Server.Utils.Math.MathHelper

Contains commonly used precalculated values and mathematical operations.
Afficher le fichier Open project: GrindFest/GrindFest

Méthodes publiques

Méthode Description
Barycentric ( float value1, float value2, float value3, float amount1, float amount2 ) : float

Returns the Cartesian coordinate for one axis of a point that is defined by a given triangle and two normalized barycentric (areal) coordinates.

CatmullRom ( float value1, float value2, float value3, float value4, float amount ) : float

Performs a Catmull-Rom interpolation using the specified positions.

Clamp ( float value, float min, float max ) : float

Restricts a value to be within a specified range.

Clamp ( int value, int min, int max ) : int

Restricts a value to be within a specified range.

Distance ( float value1, float value2 ) : float

Calculates the absolute value of the difference of two values.

Hermite ( float value1, float tangent1, float value2, float tangent2, float amount ) : float

Performs a Hermite spline interpolation.

IsPowerOfTwo ( int value ) : bool

Determines if value is powered by two.

Lerp ( float value1, float value2, float amount ) : float

Linearly interpolates between two values.

This method performs the linear interpolation based on the following formula. value1 + (value2 - value1) * amount Passing amount a value of 0 will cause value1 to be returned, a value of 1 will cause value2 to be returned.

Max ( float value1, float value2 ) : float

Returns the greater of two values.

Min ( float value1, float value2 ) : float

Returns the lesser of two values.

SmoothStep ( float value1, float value2, float amount ) : float

Interpolates between two values using a cubic equation.

ToDegrees ( float radians ) : float

Converts radians to degrees.

This method uses double precission internally, though it returns single float Factor = 180 / pi

ToRadians ( float degrees ) : float

Converts degrees to radians.

This method uses double precission internally, though it returns single float Factor = pi / 180

WrapAngle ( float angle ) : float

Reduces a given angle to a value between π and -π.

Method Details

Barycentric() public static méthode

Returns the Cartesian coordinate for one axis of a point that is defined by a given triangle and two normalized barycentric (areal) coordinates.
public static Barycentric ( float value1, float value2, float value3, float amount1, float amount2 ) : float
value1 float The coordinate on one axis of vertex 1 of the defining triangle.
value2 float The coordinate on the same axis of vertex 2 of the defining triangle.
value3 float The coordinate on the same axis of vertex 3 of the defining triangle.
amount1 float The normalized barycentric (areal) coordinate b2, equal to the weighting factor for vertex 2, the coordinate of which is specified in value2.
amount2 float The normalized barycentric (areal) coordinate b3, equal to the weighting factor for vertex 3, the coordinate of which is specified in value3.
Résultat float

CatmullRom() public static méthode

Performs a Catmull-Rom interpolation using the specified positions.
public static CatmullRom ( float value1, float value2, float value3, float value4, float amount ) : float
value1 float The first position in the interpolation.
value2 float The second position in the interpolation.
value3 float The third position in the interpolation.
value4 float The fourth position in the interpolation.
amount float Weighting factor.
Résultat float

Clamp() public static méthode

Restricts a value to be within a specified range.
public static Clamp ( float value, float min, float max ) : float
value float The value to clamp.
min float The minimum value. If value is less than min, min will be returned.
max float The maximum value. If value is greater than max, max will be returned.
Résultat float

Clamp() public static méthode

Restricts a value to be within a specified range.
public static Clamp ( int value, int min, int max ) : int
value int The value to clamp.
min int The minimum value. If value is less than min, min will be returned.
max int The maximum value. If value is greater than max, max will be returned.
Résultat int

Distance() public static méthode

Calculates the absolute value of the difference of two values.
public static Distance ( float value1, float value2 ) : float
value1 float Source value.
value2 float Source value.
Résultat float

Hermite() public static méthode

Performs a Hermite spline interpolation.
public static Hermite ( float value1, float tangent1, float value2, float tangent2, float amount ) : float
value1 float Source position.
tangent1 float Source tangent.
value2 float Source position.
tangent2 float Source tangent.
amount float Weighting factor.
Résultat float

IsPowerOfTwo() public static méthode

Determines if value is powered by two.
public static IsPowerOfTwo ( int value ) : bool
value int A value.
Résultat bool

Lerp() public static méthode

Linearly interpolates between two values.
This method performs the linear interpolation based on the following formula. value1 + (value2 - value1) * amount Passing amount a value of 0 will cause value1 to be returned, a value of 1 will cause value2 to be returned.
public static Lerp ( float value1, float value2, float amount ) : float
value1 float Source value.
value2 float Source value.
amount float Value between 0 and 1 indicating the weight of value2.
Résultat float

Max() public static méthode

Returns the greater of two values.
public static Max ( float value1, float value2 ) : float
value1 float Source value.
value2 float Source value.
Résultat float

Min() public static méthode

Returns the lesser of two values.
public static Min ( float value1, float value2 ) : float
value1 float Source value.
value2 float Source value.
Résultat float

SmoothStep() public static méthode

Interpolates between two values using a cubic equation.
public static SmoothStep ( float value1, float value2, float amount ) : float
value1 float Source value.
value2 float Source value.
amount float Weighting value.
Résultat float

ToDegrees() public static méthode

Converts radians to degrees.
This method uses double precission internally, though it returns single float Factor = 180 / pi
public static ToDegrees ( float radians ) : float
radians float The angle in radians.
Résultat float

ToRadians() public static méthode

Converts degrees to radians.
This method uses double precission internally, though it returns single float Factor = pi / 180
public static ToRadians ( float degrees ) : float
degrees float The angle in degrees.
Résultat float

WrapAngle() public static méthode

Reduces a given angle to a value between π and -π.
public static WrapAngle ( float angle ) : float
angle float The angle to reduce, in radians.
Résultat float