> For the complete documentation index, see [llms.txt](https://kinematicsoup.gitbook.io/reactor/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kinematicsoup.gitbook.io/reactor/api-reference/ks.reactor/ks.reactor.ksmath.md).

# Class ksMath

Namespace: [KS.Reactor](/reactor/api-reference/ks.reactor.md)\
Assembly: KSCommon.dll

Collection of frequently used math algorithms and coversions of Math methods which operate on and return float values.

```csharp
public static class ksMath
```

#### Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) â† [ksMath](/reactor/api-reference/ks.reactor/ks.reactor.ksmath.md)

#### Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object\)), [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals\(system-object-system-object\)), [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype), [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone), [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Fields

### DEGREES\_TO\_RADIANS <a href="#ks_reactor_ksmath_degrees_to_radians" id="ks_reactor_ksmath_degrees_to_radians"></a>

```csharp
public const double DEGREES_TO_RADIANS = 0.017453292519943295
```

#### Field Value

[double](https://learn.microsoft.com/dotnet/api/system.double)

### Epsilon <a href="#ks_reactor_ksmath_epsilon" id="ks_reactor_ksmath_epsilon"></a>

Smallest float value that does not equate to 0. On ARM systems, the value of the Epsilon constant is too small to be detected, so it equates to zero. In this case we use the value 1.175494E-38f. <https://docs.microsoft.com/en-us/dotnet/api/system.single.epsilon?view=net-6.0#platform-notes>

```csharp
public static readonly float Epsilon
```

#### Field Value

[float](https://learn.microsoft.com/dotnet/api/system.single)

### FDEGREES\_TO\_RADIANS <a href="#ks_reactor_ksmath_fdegrees_to_radians" id="ks_reactor_ksmath_fdegrees_to_radians"></a>

```csharp
public const float FDEGREES_TO_RADIANS = 0.017453292
```

#### Field Value

[float](https://learn.microsoft.com/dotnet/api/system.single)

### FRADIANS\_TO\_DEGREES <a href="#ks_reactor_ksmath_fradians_to_degrees" id="ks_reactor_ksmath_fradians_to_degrees"></a>

```csharp
public const float FRADIANS_TO_DEGREES = 57.29578
```

#### Field Value

[float](https://learn.microsoft.com/dotnet/api/system.single)

### FTWO\_PI <a href="#ks_reactor_ksmath_ftwo_pi" id="ks_reactor_ksmath_ftwo_pi"></a>

```csharp
public const float FTWO_PI = 6.2831855
```

#### Field Value

[float](https://learn.microsoft.com/dotnet/api/system.single)

### PI <a href="#ks_reactor_ksmath_pi" id="ks_reactor_ksmath_pi"></a>

```csharp
public const float PI = 3.1415927
```

#### Field Value

[float](https://learn.microsoft.com/dotnet/api/system.single)

### RADIANS\_TO\_DEGREES <a href="#ks_reactor_ksmath_radians_to_degrees" id="ks_reactor_ksmath_radians_to_degrees"></a>

```csharp
public const double RADIANS_TO_DEGREES = 57.29577951308232
```

#### Field Value

[double](https://learn.microsoft.com/dotnet/api/system.double)

### TWO\_PI <a href="#ks_reactor_ksmath_two_pi" id="ks_reactor_ksmath_two_pi"></a>

```csharp
public const double TWO_PI = 6.283185307179586
```

#### Field Value

[double](https://learn.microsoft.com/dotnet/api/system.double)

## Methods

### Abs(float) <a href="#ks_reactor_ksmath_abs_system_single" id="ks_reactor_ksmath_abs_system_single"></a>

Returns the absolute value of f.

```csharp
public static float Abs(float f)
```

#### Parameters

`f` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Abs(int) <a href="#ks_reactor_ksmath_abs_system_int32" id="ks_reactor_ksmath_abs_system_int32"></a>

Returns the absolute value of f.

```csharp
public static int Abs(int value)
```

#### Parameters

`value` [int](https://learn.microsoft.com/dotnet/api/system.int32)

#### Returns

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### Acos(float) <a href="#ks_reactor_ksmath_acos_system_single" id="ks_reactor_ksmath_acos_system_single"></a>

Returns the arc-cosine of f - the angle in radians whose cosine is f.

```csharp
public static float Acos(float f)
```

#### Parameters

`f` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Approximately(float, float, float) <a href="#ks_reactor_ksmath_approximately_system_single_system_single_system_single" id="ks_reactor_ksmath_approximately_system_single_system_single_system_single"></a>

Compares two floating point values and returns true if they are similar.

```csharp
public static bool Approximately(float a, float b, float tolerance = 1E-06)
```

#### Parameters

`a` [float](https://learn.microsoft.com/dotnet/api/system.single)

`b` [float](https://learn.microsoft.com/dotnet/api/system.single)

`tolerance` [float](https://learn.microsoft.com/dotnet/api/system.single)

This value is mulitplied by the largest of a or b to determine the value used for the comparison.

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### Asin(float) <a href="#ks_reactor_ksmath_asin_system_single" id="ks_reactor_ksmath_asin_system_single"></a>

Returns the absolute value of f.

```csharp
public static float Asin(float f)
```

#### Parameters

`f` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Atan(float) <a href="#ks_reactor_ksmath_atan_system_single" id="ks_reactor_ksmath_atan_system_single"></a>

Returns the arc-tangent of f - the angle in radians whose tangent is f.

```csharp
public static float Atan(float f)
```

#### Parameters

`f` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Atan2(float, float) <a href="#ks_reactor_ksmath_atan2_system_single_system_single" id="ks_reactor_ksmath_atan2_system_single_system_single"></a>

Returns the angle in radians whose Tan is y/x.

```csharp
public static float Atan2(float y, float x)
```

#### Parameters

`y` [float](https://learn.microsoft.com/dotnet/api/system.single)

`x` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Ceil(float) <a href="#ks_reactor_ksmath_ceil_system_single" id="ks_reactor_ksmath_ceil_system_single"></a>

Returns the smallest integer greater to or equal to f.

```csharp
public static float Ceil(float f)
```

#### Parameters

`f` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### CeilToInt(float) <a href="#ks_reactor_ksmath_ceiltoint_system_single" id="ks_reactor_ksmath_ceiltoint_system_single"></a>

Returns the smallest integer greater to or equal to f.

```csharp
public static int CeilToInt(float f)
```

#### Parameters

`f` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### Clamp(float, float, float) <a href="#ks_reactor_ksmath_clamp_system_single_system_single_system_single" id="ks_reactor_ksmath_clamp_system_single_system_single_system_single"></a>

Clamps the given value between the given minimum float and maximum float values. Returns the given value if it is within the min and max range.

```csharp
public static float Clamp(float value, float min, float max)
```

#### Parameters

`value` [float](https://learn.microsoft.com/dotnet/api/system.single)

`min` [float](https://learn.microsoft.com/dotnet/api/system.single)

`max` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Clamp(int, int, int) <a href="#ks_reactor_ksmath_clamp_system_int32_system_int32_system_int32" id="ks_reactor_ksmath_clamp_system_int32_system_int32_system_int32"></a>

Clamps the given value between the given minimum int and maximum int values. Returns the given value if it is within the min and max range.

```csharp
public static int Clamp(int value, int min, int max)
```

#### Parameters

`value` [int](https://learn.microsoft.com/dotnet/api/system.int32)

`min` [int](https://learn.microsoft.com/dotnet/api/system.int32)

`max` [int](https://learn.microsoft.com/dotnet/api/system.int32)

#### Returns

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### Clamp01(float) <a href="#ks_reactor_ksmath_clamp01_system_single" id="ks_reactor_ksmath_clamp01_system_single"></a>

Clamps value between 0 and 1 and returns value.

```csharp
public static float Clamp01(float value)
```

#### Parameters

`value` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### ClosestPowerOfTwo(int) <a href="#ks_reactor_ksmath_closestpoweroftwo_system_int32" id="ks_reactor_ksmath_closestpoweroftwo_system_int32"></a>

Returns the closest power of two value.

```csharp
public static int ClosestPowerOfTwo(int value)
```

#### Parameters

`value` [int](https://learn.microsoft.com/dotnet/api/system.int32)

#### Returns

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### Cos(float) <a href="#ks_reactor_ksmath_cos_system_single" id="ks_reactor_ksmath_cos_system_single"></a>

Returns the cosine of angle f.

```csharp
public static float Cos(float f)
```

#### Parameters

`f` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### CountSetBits(int) <a href="#ks_reactor_ksmath_countsetbits_system_int32" id="ks_reactor_ksmath_countsetbits_system_int32"></a>

Count the number of bits set in an int

```csharp
public static int CountSetBits(int value)
```

#### Parameters

`value` [int](https://learn.microsoft.com/dotnet/api/system.int32)

#### Returns

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### DeltaAngle(float, float) <a href="#ks_reactor_ksmath_deltaangle_system_single_system_single" id="ks_reactor_ksmath_deltaangle_system_single_system_single"></a>

Calculates the shortest difference between two given angles given in degrees.

```csharp
public static float DeltaAngle(float current, float target)
```

#### Parameters

`current` [float](https://learn.microsoft.com/dotnet/api/system.single)

`target` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Exp(float) <a href="#ks_reactor_ksmath_exp_system_single" id="ks_reactor_ksmath_exp_system_single"></a>

Returns e raised to the specified power.

```csharp
public static float Exp(float power)
```

#### Parameters

`power` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Floor(float) <a href="#ks_reactor_ksmath_floor_system_single" id="ks_reactor_ksmath_floor_system_single"></a>

Returns the largest integer smaller than or equal to f.

```csharp
public static float Floor(float f)
```

#### Parameters

`f` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### FloorToInt(float) <a href="#ks_reactor_ksmath_floortoint_system_single" id="ks_reactor_ksmath_floortoint_system_single"></a>

Returns the largest integer smaller to or equal to f.

```csharp
public static int FloorToInt(float f)
```

#### Parameters

`f` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### Gamma(float, float, float) <a href="#ks_reactor_ksmath_gamma_system_single_system_single_system_single" id="ks_reactor_ksmath_gamma_system_single_system_single_system_single"></a>

Normalize a value between negative `absmax` and positive `absmax` to -1...1 then raise the result to a power before remapping it into negative `absmax` to `absmax`.

```csharp
public static float Gamma(float value, float absmax, float power)
```

#### Parameters

`value` [float](https://learn.microsoft.com/dotnet/api/system.single)

`absmax` [float](https://learn.microsoft.com/dotnet/api/system.single)

`power` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Interpolate(float, float, float, Interpolation) <a href="#ks_reactor_ksmath_interpolate_system_single_system_single_system_single_ks_reactor_ksmath_interpolat" id="ks_reactor_ksmath_interpolate_system_single_system_single_system_single_ks_reactor_ksmath_interpolat"></a>

Interpolate between the value a and b according to an interpolation method.

```csharp
public static float Interpolate(float a, float b, float t, ksMath.Interpolation equation)
```

#### Parameters

`a` [float](https://learn.microsoft.com/dotnet/api/system.single)

`b` [float](https://learn.microsoft.com/dotnet/api/system.single)

`t` [float](https://learn.microsoft.com/dotnet/api/system.single)

`equation` [ksMath](/reactor/api-reference/ks.reactor/ks.reactor.ksmath.md).[Interpolation](/reactor/api-reference/ks.reactor/ks.reactor.ksmath/ks.reactor.ksmath.interpolation.md)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### InverseLerp(float, float, float) <a href="#ks_reactor_ksmath_inverselerp_system_single_system_single_system_single" id="ks_reactor_ksmath_inverselerp_system_single_system_single_system_single"></a>

Calculates the linear parameter t that produces the interpolant value within the range \[a, b].

```csharp
public static float InverseLerp(float a, float b, float value)
```

#### Parameters

`a` [float](https://learn.microsoft.com/dotnet/api/system.single)

`b` [float](https://learn.microsoft.com/dotnet/api/system.single)

`value` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### IsPowerOfTwo(int) <a href="#ks_reactor_ksmath_ispoweroftwo_system_int32" id="ks_reactor_ksmath_ispoweroftwo_system_int32"></a>

Returns true if the value is power of two.

```csharp
public static bool IsPowerOfTwo(int value)
```

#### Parameters

`value` [int](https://learn.microsoft.com/dotnet/api/system.int32)

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### Lerp(float, float, float) <a href="#ks_reactor_ksmath_lerp_system_single_system_single_system_single" id="ks_reactor_ksmath_lerp_system_single_system_single_system_single"></a>

Linearly interpolates between a and b by t.

```csharp
public static float Lerp(float a, float b, float t)
```

#### Parameters

`a` [float](https://learn.microsoft.com/dotnet/api/system.single)

`b` [float](https://learn.microsoft.com/dotnet/api/system.single)

`t` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### LerpAngle(float, float, float) <a href="#ks_reactor_ksmath_lerpangle_system_single_system_single_system_single" id="ks_reactor_ksmath_lerpangle_system_single_system_single_system_single"></a>

Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.

```csharp
public static float LerpAngle(float a, float b, float t)
```

#### Parameters

`a` [float](https://learn.microsoft.com/dotnet/api/system.single)

`b` [float](https://learn.microsoft.com/dotnet/api/system.single)

`t` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### LerpUnclamped(float, float, float) <a href="#ks_reactor_ksmath_lerpunclamped_system_single_system_single_system_single" id="ks_reactor_ksmath_lerpunclamped_system_single_system_single_system_single"></a>

Linearly interpolates between a and b by t with no limit to t.

```csharp
public static float LerpUnclamped(float a, float b, float t)
```

#### Parameters

`a` [float](https://learn.microsoft.com/dotnet/api/system.single)

`b` [float](https://learn.microsoft.com/dotnet/api/system.single)

`t` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### LineIntersection(ksVector2, ksVector2, ksVector2, ksVector2, ref ksVector2) <a href="#ks_reactor_ksmath_lineintersection_ks_reactor_ksvector2_ks_reactor_ksvector2_ks_reactor_ksvector2_ks" id="ks_reactor_ksmath_lineintersection_ks_reactor_ksvector2_ks_reactor_ksvector2_ks_reactor_ksvector2_ks"></a>

Check if the line (p1,p2) intersects with line (p3, p4)

```csharp
public static bool LineIntersection(ksVector2 p1, ksVector2 p2, ksVector2 p3, ksVector2 p4, ref ksVector2 result)
```

#### Parameters

`p1` [ksVector2](/reactor/api-reference/ks.reactor/ks.reactor.ksvector2.md)

`p2` [ksVector2](/reactor/api-reference/ks.reactor/ks.reactor.ksvector2.md)

`p3` [ksVector2](/reactor/api-reference/ks.reactor/ks.reactor.ksvector2.md)

`p4` [ksVector2](/reactor/api-reference/ks.reactor/ks.reactor.ksvector2.md)

`result` [ksVector2](/reactor/api-reference/ks.reactor/ks.reactor.ksvector2.md)

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### LineSegmentIntersection(ksVector2, ksVector2, ksVector2, ksVector2, ref ksVector2) <a href="#ks_reactor_ksmath_linesegmentintersection_ks_reactor_ksvector2_ks_reactor_ksvector2_ks_reactor_ksvec" id="ks_reactor_ksmath_linesegmentintersection_ks_reactor_ksvector2_ks_reactor_ksvector2_ks_reactor_ksvec"></a>

Check if the line segment (p1,p2) intersects with the line segment (p3, p4)

```csharp
public static bool LineSegmentIntersection(ksVector2 p1, ksVector2 p2, ksVector2 p3, ksVector2 p4, ref ksVector2 result)
```

#### Parameters

`p1` [ksVector2](/reactor/api-reference/ks.reactor/ks.reactor.ksvector2.md)

`p2` [ksVector2](/reactor/api-reference/ks.reactor/ks.reactor.ksvector2.md)

`p3` [ksVector2](/reactor/api-reference/ks.reactor/ks.reactor.ksvector2.md)

`p4` [ksVector2](/reactor/api-reference/ks.reactor/ks.reactor.ksvector2.md)

`result` [ksVector2](/reactor/api-reference/ks.reactor/ks.reactor.ksvector2.md)

#### Returns

[bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### Log(float, float) <a href="#ks_reactor_ksmath_log_system_single_system_single" id="ks_reactor_ksmath_log_system_single_system_single"></a>

Returns the logarithm of a specified number in a specified base.

```csharp
public static float Log(float f, float p)
```

#### Parameters

`f` [float](https://learn.microsoft.com/dotnet/api/system.single)

`p` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Log(float) <a href="#ks_reactor_ksmath_log_system_single" id="ks_reactor_ksmath_log_system_single"></a>

Returns the logarithm of a specified number in a specified base.

```csharp
public static float Log(float f)
```

#### Parameters

`f` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Log10(float) <a href="#ks_reactor_ksmath_log10_system_single" id="ks_reactor_ksmath_log10_system_single"></a>

Returns the base 10 logarithm of a specified number.

```csharp
public static float Log10(float f)
```

#### Parameters

`f` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Max(float, float) <a href="#ks_reactor_ksmath_max_system_single_system_single" id="ks_reactor_ksmath_max_system_single_system_single"></a>

Returns largest of two or more values.

```csharp
public static float Max(float a, float b)
```

#### Parameters

`a` [float](https://learn.microsoft.com/dotnet/api/system.single)

`b` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Max(params float\[]) <a href="#ks_reactor_ksmath_max_system_single" id="ks_reactor_ksmath_max_system_single"></a>

Returns largest of two or more values.

```csharp
public static float Max(params float[] values)
```

#### Parameters

`values` [float](https://learn.microsoft.com/dotnet/api/system.single)\[]

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Max(int, int) <a href="#ks_reactor_ksmath_max_system_int32_system_int32" id="ks_reactor_ksmath_max_system_int32_system_int32"></a>

Returns largest of two or more values.

```csharp
public static int Max(int a, int b)
```

#### Parameters

`a` [int](https://learn.microsoft.com/dotnet/api/system.int32)

`b` [int](https://learn.microsoft.com/dotnet/api/system.int32)

#### Returns

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### Max(params int\[]) <a href="#ks_reactor_ksmath_max_system_int32" id="ks_reactor_ksmath_max_system_int32"></a>

Returns largest of two or more values.

```csharp
public static int Max(params int[] values)
```

#### Parameters

`values` [int](https://learn.microsoft.com/dotnet/api/system.int32)\[]

#### Returns

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### MaxSetBit(int) <a href="#ks_reactor_ksmath_maxsetbit_system_int32" id="ks_reactor_ksmath_maxsetbit_system_int32"></a>

Get the highest bit set from 1 to 32. If no bits are set, then this method returns 0.

```csharp
public static int MaxSetBit(int value)
```

#### Parameters

`value` [int](https://learn.microsoft.com/dotnet/api/system.int32)

#### Returns

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### Min(float, float) <a href="#ks_reactor_ksmath_min_system_single_system_single" id="ks_reactor_ksmath_min_system_single_system_single"></a>

Returns the smallest of two or more values.

```csharp
public static float Min(float a, float b)
```

#### Parameters

`a` [float](https://learn.microsoft.com/dotnet/api/system.single)

`b` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Min(params float\[]) <a href="#ks_reactor_ksmath_min_system_single" id="ks_reactor_ksmath_min_system_single"></a>

Returns the smallest of two or more values.

```csharp
public static float Min(params float[] values)
```

#### Parameters

`values` [float](https://learn.microsoft.com/dotnet/api/system.single)\[]

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Min(int, int) <a href="#ks_reactor_ksmath_min_system_int32_system_int32" id="ks_reactor_ksmath_min_system_int32_system_int32"></a>

Returns the smallest of two or more values.

```csharp
public static int Min(int a, int b)
```

#### Parameters

`a` [int](https://learn.microsoft.com/dotnet/api/system.int32)

`b` [int](https://learn.microsoft.com/dotnet/api/system.int32)

#### Returns

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### Min(params int\[]) <a href="#ks_reactor_ksmath_min_system_int32" id="ks_reactor_ksmath_min_system_int32"></a>

Returns the smallest of two or more values.

```csharp
public static int Min(params int[] values)
```

#### Parameters

`values` [int](https://learn.microsoft.com/dotnet/api/system.int32)\[]

#### Returns

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### MoveTowards(float, float, float) <a href="#ks_reactor_ksmath_movetowards_system_single_system_single_system_single" id="ks_reactor_ksmath_movetowards_system_single_system_single_system_single"></a>

Moves a value current towards target. A negative value moves the value away from the target.

```csharp
public static float MoveTowards(float current, float target, float maxDelta)
```

#### Parameters

`current` [float](https://learn.microsoft.com/dotnet/api/system.single)

`target` [float](https://learn.microsoft.com/dotnet/api/system.single)

`maxDelta` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### MoveTowardsAngle(float, float, float) <a href="#ks_reactor_ksmath_movetowardsangle_system_single_system_single_system_single" id="ks_reactor_ksmath_movetowardsangle_system_single_system_single_system_single"></a>

Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.

```csharp
public static float MoveTowardsAngle(float current, float target, float maxDelta)
```

#### Parameters

`current` [float](https://learn.microsoft.com/dotnet/api/system.single)

`target` [float](https://learn.microsoft.com/dotnet/api/system.single)

`maxDelta` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### NextPowerOfTwo(int) <a href="#ks_reactor_ksmath_nextpoweroftwo_system_int32" id="ks_reactor_ksmath_nextpoweroftwo_system_int32"></a>

Returns the next power of two that is equal to, or greater than, the argument.

```csharp
public static int NextPowerOfTwo(int value)
```

#### Parameters

`value` [int](https://learn.microsoft.com/dotnet/api/system.int32)

#### Returns

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### PerlinNoise(float, float, float, float) <a href="#ks_reactor_ksmath_perlinnoise_system_single_system_single_system_single_system_single" id="ks_reactor_ksmath_perlinnoise_system_single_system_single_system_single_system_single"></a>

Generate Perlin noise.

```csharp
public static float PerlinNoise(float x, float y = 0, float z = 0, float range = 1)
```

#### Parameters

`x` [float](https://learn.microsoft.com/dotnet/api/system.single)

X value

`y` [float](https://learn.microsoft.com/dotnet/api/system.single)

Y value

`z` [float](https://learn.microsoft.com/dotnet/api/system.single)

Z value

`range` [float](https://learn.microsoft.com/dotnet/api/system.single)

Values will be remapped onto \[0...range) using value%range.

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### PingPong(float, float) <a href="#ks_reactor_ksmath_pingpong_system_single_system_single" id="ks_reactor_ksmath_pingpong_system_single_system_single"></a>

PingPong returns a value that will increment and decrement between the value 0 and length.

```csharp
public static float PingPong(float t, float length)
```

#### Parameters

`t` [float](https://learn.microsoft.com/dotnet/api/system.single)

`length` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Pow(float, float) <a href="#ks_reactor_ksmath_pow_system_single_system_single" id="ks_reactor_ksmath_pow_system_single_system_single"></a>

Returns f raised to power p.

```csharp
public static float Pow(float f, float p)
```

#### Parameters

`f` [float](https://learn.microsoft.com/dotnet/api/system.single)

`p` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Repeat(float, float) <a href="#ks_reactor_ksmath_repeat_system_single_system_single" id="ks_reactor_ksmath_repeat_system_single_system_single"></a>

Loops the value t, so that it is never larger than length and never smaller than 0.

```csharp
public static float Repeat(float t, float length)
```

#### Parameters

`t` [float](https://learn.microsoft.com/dotnet/api/system.single)

`length` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Round(float) <a href="#ks_reactor_ksmath_round_system_single" id="ks_reactor_ksmath_round_system_single"></a>

Returns f rounded to the nearest integer.

```csharp
public static float Round(float f)
```

#### Parameters

`f` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### RoundToInt(float) <a href="#ks_reactor_ksmath_roundtoint_system_single" id="ks_reactor_ksmath_roundtoint_system_single"></a>

Returns f rounded to the nearest integer.

```csharp
public static int RoundToInt(float f)
```

#### Parameters

`f` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[int](https://learn.microsoft.com/dotnet/api/system.int32)

### Sign(float) <a href="#ks_reactor_ksmath_sign_system_single" id="ks_reactor_ksmath_sign_system_single"></a>

Returns the sign of f.

```csharp
public static float Sign(float f)
```

#### Parameters

`f` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Sin(float) <a href="#ks_reactor_ksmath_sin_system_single" id="ks_reactor_ksmath_sin_system_single"></a>

Returns the sine of angle f.

```csharp
public static float Sin(float f)
```

#### Parameters

`f` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### SmoothDamp(float, float, ref float, float, float, float) <a href="#ks_reactor_ksmath_smoothdamp_system_single_system_single_system_single__system_single_system_single" id="ks_reactor_ksmath_smoothdamp_system_single_system_single_system_single__system_single_system_single"></a>

Gradually changes a value towards a desired goal over time.

```csharp
public static float SmoothDamp(float current, float target, ref float currentVelocity, float smoothTime, float deltaTime, float maxSpeed = Infinity)
```

#### Parameters

`current` [float](https://learn.microsoft.com/dotnet/api/system.single)

`target` [float](https://learn.microsoft.com/dotnet/api/system.single)

`currentVelocity` [float](https://learn.microsoft.com/dotnet/api/system.single)

`smoothTime` [float](https://learn.microsoft.com/dotnet/api/system.single)

`deltaTime` [float](https://learn.microsoft.com/dotnet/api/system.single)

`maxSpeed` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### SmoothDampAngle(float, float, ref float, float, float, float) <a href="#ks_reactor_ksmath_smoothdampangle_system_single_system_single_system_single__system_single_system_si" id="ks_reactor_ksmath_smoothdampangle_system_single_system_single_system_single__system_single_system_si"></a>

Gradually changes an angle given in degrees towards a desired goal angle over time.

```csharp
public static float SmoothDampAngle(float current, float target, ref float currentVelocity, float smoothTime, float deltaTime, float maxSpeed = Infinity)
```

#### Parameters

`current` [float](https://learn.microsoft.com/dotnet/api/system.single)

`target` [float](https://learn.microsoft.com/dotnet/api/system.single)

`currentVelocity` [float](https://learn.microsoft.com/dotnet/api/system.single)

`smoothTime` [float](https://learn.microsoft.com/dotnet/api/system.single)

`deltaTime` [float](https://learn.microsoft.com/dotnet/api/system.single)

`maxSpeed` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### SmoothStep(float, float, float) <a href="#ks_reactor_ksmath_smoothstep_system_single_system_single_system_single" id="ks_reactor_ksmath_smoothstep_system_single_system_single_system_single"></a>

Interpolates between min and max with smoothing at the limits.

```csharp
public static float SmoothStep(float from, float to, float t)
```

#### Parameters

`from` [float](https://learn.microsoft.com/dotnet/api/system.single)

`to` [float](https://learn.microsoft.com/dotnet/api/system.single)

`t` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Sqrt(float) <a href="#ks_reactor_ksmath_sqrt_system_single" id="ks_reactor_ksmath_sqrt_system_single"></a>

Returns square root of f.

```csharp
public static float Sqrt(float f)
```

#### Parameters

`f` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)

### Tan(float) <a href="#ks_reactor_ksmath_tan_system_single" id="ks_reactor_ksmath_tan_system_single"></a>

Returns the tangent of angle f in radians.

```csharp
public static float Tan(float f)
```

#### Parameters

`f` [float](https://learn.microsoft.com/dotnet/api/system.single)

#### Returns

[float](https://learn.microsoft.com/dotnet/api/system.single)
