# MathHelper Class (Microsoft.Xna.Framework)

Contains commonly used precalculated values and mathematical operations.

- C#
- VB
- F#

public static class MathHelper

Syntax for VB is not yet implemented.

Syntax for F# is not yet implemented.

The MathHelper type exposes the following members.

Platforms | Name | Description | |
---|---|---|---|

E | Represents the mathematical constant e(2.71828175). | ||

Log10E | Represents the log base ten of e(0.4342945). | ||

Log2E | Represents the log base two of e(1.442695). | ||

Pi | Represents the value of pi(3.14159274). | ||

PiOver2 | Represents the value of pi divided by two(1.57079637). | ||

PiOver4 | Represents the value of pi divided by four(0.7853982). | ||

TwoPi | Represents the value of pi times two(6.28318548). |

Platforms | Name | Description | |
---|---|---|---|

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

CatmullRom | Performs a Catmull-Rom interpolation using the specified positions. | ||

Clamp(float, float, float) | Restricts a value to be within a specified range. | ||

Clamp(int, int, int) | Restricts a value to be within a specified range. | ||

Distance | Calculates the absolute value of the difference of two values. | ||

Hermite | Performs a Hermite spline interpolation. | ||

IsPowerOfTwo | Determines if value is powered by two. | ||

Lerp | Linearly interpolates between two values. | ||

LerpPrecise | Linearly interpolates between two values. This method is a less efficient, more precise version of Lerp(float, float, float). See remarks for more info. | ||

Max(float, float) | Returns the greater of two values. | ||

Max(int, int) | Returns the greater of two values. | ||

Min(int, int) | Returns the lesser of two values. | ||

Min(float, float) | Returns the lesser of two values. | ||

SmoothStep | Interpolates between two values using a cubic equation. | ||

ToDegrees | Converts radians to degrees. | ||

ToRadians | Converts degrees to radians. | ||

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

Supported in:

Windows DirectX Desktop

Linux Desktop

Windows OpenGL Desktop

Web

Windows DirectX Desktop

Linux Desktop

Windows OpenGL Desktop

Web