C# Class VRageMath.MathHelper

Contains commonly used precalculated values.
ファイルを表示 Open project: GoodAI/BrainSimulator

Public Methods

Method 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.

CalculateVectorOnSphere ( System.Vector3 northPoleDir, float phi, float theta ) : System.Vector3
CatmullRom ( float value1, float value2, float value3, float value4, float amount ) : float

Performs a Catmull-Rom interpolation using the specified positions.

Clamp ( VRage.MyFixedPoint value, VRage.MyFixedPoint min, VRage.MyFixedPoint max ) : VRage.MyFixedPoint

Restricts a value to be within a specified range. Reference page contains links to related code samples.

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

Restricts a value to be within a specified range. Reference page contains links to related code samples.

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

Restricts a value to be within a specified range. Reference page contains links to related code samples.

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

Restricts a value to be within a specified range. Reference page contains links to related code samples.

ComputeHashFromBytes ( byte bytes ) : int
CubicInterp ( double p0, double p1, double p2, double p3, double t ) : double
Distance ( float value1, float value2 ) : float

Calculates the absolute value of the difference of two values.

Floor ( double n ) : int
Floor ( float n ) : int
GetNearestBiggerPowerOfTwo ( double f ) : int
GetNearestBiggerPowerOfTwo ( float f ) : int

Returns nearest bigger power of two

GetNearestBiggerPowerOfTwo ( int v ) : int
GetNearestBiggerPowerOfTwo ( uint v ) : uint
Hermite ( float value1, float tangent1, float value2, float tangent2, float amount ) : float

Performs a Hermite spline interpolation.

InterpLog ( float value, float amount1, float amount2 ) : float

Performs interpolation on logarithmic scale.

InterpLogInv ( float value, float amount1, float amount2 ) : float
IsPowerOfTwo ( int x ) : bool

Returns true if value is power of two

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

Linearly interpolates between two values.

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

Linearly interpolates between two values.

LimitRadians ( float &angle ) : void

Returns angle in range 0..2*PI

LimitRadians2PI ( double &angle ) : void

Returns angle in range 0..2*PI

LimitRadians2PI ( float &angle ) : void

Returns angle in range 0..2*PI

LimitRadiansPI ( double &angle ) : void

Returns angle in range -PI..PI

LimitRadiansPI ( float &angle ) : void

Returns angle in range -PI..PI

Log2 ( int n ) : int
Log2 ( uint n ) : int
Log2Ceiling ( int value ) : int
Log2Floor ( int value ) : int
Max ( double value1, double value2 ) : double

Returns the greater of two values.

Max ( double a, double b, double c ) : double
Max ( float value1, float value2 ) : float

Returns the greater of two values.

Max ( float a, float b, float c ) : float
Max ( int a, int b, int c ) : int
Min ( double value1, double value2 ) : double

Returns the lesser of two values.

Min ( double a, double b, double c ) : double
Min ( float value1, float value2 ) : float

Returns the lesser of two values.

Min ( float a, float b, float c ) : float
MonotonicAcos ( float cos ) : float
MonotonicCosine ( float radians ) : float
Pow2 ( int n ) : int

Returns 2^n

RoundOn2 ( float x ) : float
SCurve3 ( double t ) : double
SCurve3 ( float t ) : float
SCurve5 ( double t ) : double
SCurve5 ( float t ) : float
Saturate ( double n ) : double
Saturate ( float n ) : float
SmoothStep ( float value1, float value2, float amount ) : float

Interpolates between two values using a cubic equation.

ToDegrees ( double radians ) : double
ToDegrees ( float radians ) : float

Converts radians to degrees.

ToRadians ( float degrees ) : float

Converts degrees to radians.

WrapAngle ( float angle ) : float

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

Method Details

Barycentric() public static method

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.
return float

CalculateVectorOnSphere() public static method

public static CalculateVectorOnSphere ( System.Vector3 northPoleDir, float phi, float theta ) : System.Vector3
northPoleDir System.Vector3
phi float
theta float
return System.Vector3

CatmullRom() public static method

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.
return float

Clamp() public static method

Restricts a value to be within a specified range. Reference page contains links to related code samples.
public static Clamp ( VRage.MyFixedPoint value, VRage.MyFixedPoint min, VRage.MyFixedPoint max ) : VRage.MyFixedPoint
value VRage.MyFixedPoint The value to clamp.
min VRage.MyFixedPoint The minimum value. If value is less than min, min will be returned.
max VRage.MyFixedPoint The maximum value. If value is greater than max, max will be returned.
return VRage.MyFixedPoint

Clamp() public static method

Restricts a value to be within a specified range. Reference page contains links to related code samples.
public static Clamp ( double value, double min, double max ) : double
value double The value to clamp.
min double The minimum value. If value is less than min, min will be returned.
max double The maximum value. If value is greater than max, max will be returned.
return double

Clamp() public static method

Restricts a value to be within a specified range. Reference page contains links to related code samples.
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.
return float

Clamp() public static method

Restricts a value to be within a specified range. Reference page contains links to related code samples.
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.
return int

ComputeHashFromBytes() public static method

public static ComputeHashFromBytes ( byte bytes ) : int
bytes byte
return int

CubicInterp() public static method

public static CubicInterp ( double p0, double p1, double p2, double p3, double t ) : double
p0 double
p1 double
p2 double
p3 double
t double
return double

Distance() public static method

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.
return float

Floor() public static method

public static Floor ( double n ) : int
n double
return int

Floor() public static method

public static Floor ( float n ) : int
n float
return int

GetNearestBiggerPowerOfTwo() public static method

public static GetNearestBiggerPowerOfTwo ( double f ) : int
f double
return int

GetNearestBiggerPowerOfTwo() public static method

Returns nearest bigger power of two
public static GetNearestBiggerPowerOfTwo ( float f ) : int
f float
return int

GetNearestBiggerPowerOfTwo() public static method

public static GetNearestBiggerPowerOfTwo ( int v ) : int
v int
return int

GetNearestBiggerPowerOfTwo() public static method

public static GetNearestBiggerPowerOfTwo ( uint v ) : uint
v uint
return uint

Hermite() public static method

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.
return float

InterpLog() public static method

Performs interpolation on logarithmic scale.
public static InterpLog ( float value, float amount1, float amount2 ) : float
value float
amount1 float
amount2 float
return float

InterpLogInv() public static method

public static InterpLogInv ( float value, float amount1, float amount2 ) : float
value float
amount1 float
amount2 float
return float

IsPowerOfTwo() public static method

Returns true if value is power of two
public static IsPowerOfTwo ( int x ) : bool
x int
return bool

Lerp() public static method

Linearly interpolates between two values.
public static Lerp ( double value1, double value2, double amount ) : double
value1 double Source value.
value2 double Source value.
amount double Value between 0 and 1 indicating the weight of value2.
return double

Lerp() public static method

Linearly interpolates between two values.
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.
return float

LimitRadians() public static method

Returns angle in range 0..2*PI
public static LimitRadians ( float &angle ) : void
angle float in radians
return void

LimitRadians2PI() public static method

Returns angle in range 0..2*PI
public static LimitRadians2PI ( double &angle ) : void
angle double in radians
return void

LimitRadians2PI() public static method

Returns angle in range 0..2*PI
public static LimitRadians2PI ( float &angle ) : void
angle float in radians
return void

LimitRadiansPI() public static method

Returns angle in range -PI..PI
public static LimitRadiansPI ( double &angle ) : void
angle double radians
return void

LimitRadiansPI() public static method

Returns angle in range -PI..PI
public static LimitRadiansPI ( float &angle ) : void
angle float radians
return void

Log2() public static method

public static Log2 ( int n ) : int
n int
return int

Log2() public static method

public static Log2 ( uint n ) : int
n uint
return int

Log2Ceiling() public static method

public static Log2Ceiling ( int value ) : int
value int
return int

Log2Floor() public static method

public static Log2Floor ( int value ) : int
value int
return int

Max() public static method

Returns the greater of two values.
public static Max ( double value1, double value2 ) : double
value1 double Source value.
value2 double Source value.
return double

Max() public static method

public static Max ( double a, double b, double c ) : double
a double
b double
c double
return double

Max() public static method

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

Max() public static method

public static Max ( float a, float b, float c ) : float
a float
b float
c float
return float

Max() public static method

public static Max ( int a, int b, int c ) : int
a int
b int
c int
return int

Min() public static method

Returns the lesser of two values.
public static Min ( double value1, double value2 ) : double
value1 double Source value.
value2 double Source value.
return double

Min() public static method

public static Min ( double a, double b, double c ) : double
a double
b double
c double
return double

Min() public static method

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

Min() public static method

public static Min ( float a, float b, float c ) : float
a float
b float
c float
return float

MonotonicAcos() public static method

public static MonotonicAcos ( float cos ) : float
cos float
return float

MonotonicCosine() public static method

public static MonotonicCosine ( float radians ) : float
radians float
return float

Pow2() public static method

Returns 2^n
public static Pow2 ( int n ) : int
n int
return int

RoundOn2() public static method

public static RoundOn2 ( float x ) : float
x float
return float

SCurve3() public static method

public static SCurve3 ( double t ) : double
t double
return double

SCurve3() public static method

public static SCurve3 ( float t ) : float
t float
return float

SCurve5() public static method

public static SCurve5 ( double t ) : double
t double
return double

SCurve5() public static method

public static SCurve5 ( float t ) : float
t float
return float

Saturate() public static method

public static Saturate ( double n ) : double
n double
return double

Saturate() public static method

public static Saturate ( float n ) : float
n float
return float

SmoothStep() public static method

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.
return float

ToDegrees() public static method

public static ToDegrees ( double radians ) : double
radians double
return double

ToDegrees() public static method

Converts radians to degrees.
public static ToDegrees ( float radians ) : float
radians float The angle in radians.
return float

ToRadians() public static method

Converts degrees to radians.
public static ToRadians ( float degrees ) : float
degrees float The angle in degrees.
return float

WrapAngle() public static method

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