Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

VRageMath.MathHelper

Malware edited this page Oct 22, 2024 · 47 revisions

IndexNamespace Index

MathHelper Class

public abstract sealed class MathHelper

Contains commonly used precalculated values.

Namespace: VRageMath
Assembly: VRage.Math.dll

Fields

static float E

Represents the mathematical constant e.

static float EPSILON

static float EPSILON10

static float FourPi

Represents the value of pi times two.

static float Log10E

Represents the log base ten of e.

static float Log2E

Represents the log base two of e.

static float Pi

Represents the value of pi.

static float PiOver2

Represents the value of pi divided by two.

static float PiOver4

Represents the value of pi divided by four.

static float RadiansPerSecondToRPM

60 / 2*pi

static float RPMToRadiansPerMillisec

2*pi / 60000

static float RPMToRadiansPerSecond

2*pi / 60

static float Sqrt2

Represents the value of the square root of two

static float Sqrt3

Represents the value of the square root of three

static float TwoPi

Represents the value of pi times two.

Methods

static int Align(int value, int alignment)

static float Atan(float x)

Faster Atan implementation. Good only in the [-pi/2, pi/2] range.

static double Atan(double x)

Faster Atan implementation. Good only in the [-pi/2, pi/2] range.

static float Barycentric(float value1, float value2, float value3, float amount1, float amount2)

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

static Vector3D CalculateBezierPoint(double t, Vector3D p0, Vector3D p1, Vector3D p2, Vector3D p3)

static Vector3 CalculateVectorOnSphere(Vector3 northPoleDir, float phi, float theta)

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

Performs a Catmull-Rom interpolation using the specified positions.

static int CeilToInt(float x)

static int CeilToInt(double x)

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

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

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

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

static MyFixedPoint Clamp(MyFixedPoint value, MyFixedPoint min, MyFixedPoint max)

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

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

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

static byte Clamp(byte value, byte min, byte max)

Restricts a value to be within a specified range.

static int ComputeHashFromBytes(Byte&#91] bytes)

static double CubicInterp(double p0, double p1, double p2, double p3, double t)

static float Distance(float value1, float value2)

Calculates the absolute value of the difference of two values.

static int Floor(float n)

static int Floor(double n)

static int FloorToInt(float x)

static int FloorToInt(double x)

static int GetNearestBiggerPowerOfTwo(int v)

static uint GetNearestBiggerPowerOfTwo(uint v)

static int GetNearestBiggerPowerOfTwo(float f)

Returns nearest bigger power of two

static int GetNearestBiggerPowerOfTwo(double f)

static int GetNumberOfMipmaps(int v)

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

Performs a Hermite spline interpolation.

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

Performs interpolation on logarithmic scale.

static float InterpLogInv(float value, float amount1, float amount2)

static bool IsEqual(float value1, float value2)

static bool IsEqual(Vector2 value1, Vector2 value2)

static bool IsEqual(Vector3 value1, Vector3 value2)

static bool IsEqual(Quaternion value1, Quaternion value2)

static bool IsEqual(QuaternionD value1, QuaternionD value2)

static bool IsEqual(Matrix value1, Matrix value2)

static bool IsPowerOfTwo(int x)

Returns true if value is power of two

static bool IsValid(Matrix matrix)

static bool IsValid(MatrixD matrix)

static bool IsValid(Vector3 vec)

static bool IsValid(Vector3D vec)

static bool IsValid(Vector2 vec)

static bool IsValid(float f)

static bool IsValid(double f)

static bool IsValid(Vector3? vec)

static bool IsValid(Quaternion q)

static bool IsValidNormal(Vector3 vec)

static bool IsValidOrZero(Matrix matrix)

static bool IsZero(float value, float epsilon = 1E-05)

static bool IsZero(double value, float epsilon = 1E-05)

static bool IsZero(Vector3 value, float epsilon = 1E-05)

static bool IsZero(Vector3D value, float epsilon = 1E-05)

static bool IsZero(Quaternion value, float epsilon = 1E-05)

static bool IsZero(Vector4 value)

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

Linearly interpolates between two values.

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

Linearly interpolates between two values.

static void LimitRadians(ref float angle)

Returns angle in range 0..2*PI

static void LimitRadians2PI(ref double angle)

Returns angle in range 0..2*PI

static void LimitRadiansPI(ref double angle)

Returns angle in range -PI..PI

static void LimitRadiansPI(ref float angle)

Returns angle in range -PI..PI

static int Log2(int n)

static int Log2(uint n)

static int Log2Ceiling(int value)

static int Log2Floor(int value)

static float Max(float value1, float value2)

Returns the greater of two values.

static double Max(double value1, double value2)

Returns the greater of two values.

static float Max(float a, float b, float c)

static int Max(int a, int b, int c)

static double Max(double a, double b, double c)

static float Min(float value1, float value2)

Returns the lesser of two values.

static double Min(double value1, double value2)

Returns the lesser of two values.

static float Min(float a, float b, float c)

static double Min(double a, double b, double c)

static float MonotonicAcos(float cos)

static float MonotonicCosine(float radians)

Calculate the monotonic cosine of a value. Monotonic cosine is an alternative cosine encoding that is monotonic in the [-pi, pi] interval. We use this when some parameter of an onject in a planet is constrained by latitude. The 'monotonicity' is guaranteed by subtracting the cosine value from 2 if the angle is positive. So for instance MonotonicCos(pi/2) = 2. This only works in the above interval of course.

static int Pow2(int n)

Returns 2^n

static float RoundOn2(float x)

static int RoundToInt(float x)

static int RoundToInt(double x)

static float Saturate(float n)

static double Saturate(double n)

static float SCurve3(float t)

static double SCurve3(double t)

static float SCurve5(float t)

static double SCurve5(double t)

static int Smooth(int newValue, int lastSmooth)

static float Smooth(float newValue, float lastSmooth)

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

Interpolates between two values using a cubic equation.

static double SmoothStep(double value1, double value2, double amount)

Interpolates between two values using a cubic equation.

static float SmoothStepStable(float amount)

Interpolates between zero and one using cubic equiation, solved by de Casteljau.

static double SmoothStepStable(double amount)

Interpolates between zero and one using cubic equiation, solved by de Casteljau.

static float ToDegrees(float radians)

Converts radians to degrees.

static double ToDegrees(double radians)

static float ToRadians(float degrees)

Converts degrees to radians.

static Vector3 ToRadians(Vector3 v)

static double ToRadians(double degrees)

Converts degrees to radians.

static float WrapAngle(float angle)

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

Clone this wiki locally