C# Класс Server.Utils.Math.MathHelper

Contains commonly used precalculated values and mathematical operations.
Показать файл Открыть проект

Открытые методы

Метод Описание
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 -π.

Описание методов

Barycentric() публичный статический Метод

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.
Результат float

CatmullRom() публичный статический Метод

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.
Результат float

Clamp() публичный статический Метод

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.
Результат float

Clamp() публичный статический Метод

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.
Результат int

Distance() публичный статический Метод

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.
Результат float

Hermite() публичный статический Метод

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.
Результат float

IsPowerOfTwo() публичный статический Метод

Determines if value is powered by two.
public static IsPowerOfTwo ( int value ) : bool
value int A value.
Результат bool

Lerp() публичный статический Метод

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.
Результат float

Max() публичный статический Метод

Returns the greater of two values.
public static Max ( float value1, float value2 ) : float
value1 float Source value.
value2 float Source value.
Результат float

Min() публичный статический Метод

Returns the lesser of two values.
public static Min ( float value1, float value2 ) : float
value1 float Source value.
value2 float Source value.
Результат float

SmoothStep() публичный статический Метод

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.
Результат float

ToDegrees() публичный статический Метод

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.
Результат float

ToRadians() публичный статический Метод

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.
Результат float

WrapAngle() публичный статический Метод

Reduces a given angle to a value between π and -π.
public static WrapAngle ( float angle ) : float
angle float The angle to reduce, in radians.
Результат float