Table of Contents

Class MathHelper

Namespace
VisioForge.Core.Helpers
Assembly
VisioForge.Core.dll

Provides mathematical utility methods and extension methods for common mathematical operations.

public static class MathHelper

Inheritance

Inherited Members

Methods

Clamp<T>(T, T, T)

Clamps a value between a minimum and maximum range.

public static T Clamp<T>(this T val, T min, T max) where T : IComparable<T>

Parameters

val T

The value to clamp.

min T

The minimum allowed value.

max T

The maximum allowed value.

Returns

T

The clamped value. Returns min if val is less than min, max if val is greater than max, otherwise returns val.

Type Parameters

T

The type of the value to clamp. Must implement IComparable.

DegreesToRadians(double)

Converts an angle from degrees to radians.

public static double DegreesToRadians(double degrees)

Parameters

degrees double

The angle in degrees to convert.

Returns

double

The angle converted to radians.

GenRange(int, int, int)

Generates a sequence of integers within a specified range with a given step size.

public static IEnumerable<int> GenRange(int min, int max, int step)

Parameters

min int

The starting value of the range (inclusive).

max int

The ending value of the range (inclusive).

step int

The increment between each value in the sequence.

Returns

IEnumerable<int>

An enumerable sequence of integers from min to max with the specified step size.

HighWord(uint)

Extracts the high word (upper 16 bits) from a 32-bit unsigned integer.

public static uint HighWord(this uint number)

Parameters

number uint

The 32-bit unsigned integer to extract the high word from.

Returns

uint

The upper 16 bits of the input number as a 32-bit unsigned integer.

Hypot(double, double)

Calculates the length of the hypotenuse of a right triangle given the lengths of the two other sides.

public static double Hypot(double x, double y)

Parameters

x double

The length of one side of the right triangle.

y double

The length of the other side of the right triangle.

Returns

double

The length of the hypotenuse, calculated as sqrt(x² + y²).

IsIntInRange(int, int, int)

Determines whether an integer value is within a specified range (inclusive).

public static bool IsIntInRange(int value, int min, int max)

Parameters

value int

The value to check.

min int

The minimum value of the range (inclusive).

max int

The maximum value of the range (inclusive).

Returns

bool

True if the value is within the range [min, max], false otherwise.

LowWord(uint)

Extracts the low word (lower 16 bits) from a 32-bit unsigned integer.

public static uint LowWord(this uint number)

Parameters

number uint

The 32-bit unsigned integer to extract the low word from.

Returns

uint

The lower 16 bits of the input number as a 32-bit unsigned integer.

RoundToSpecial(int, int)

Rounds a value down to the nearest multiple of a specified number.

public static int RoundToSpecial(int value, int roundTo)

Parameters

value int

The value to round.

roundTo int

The multiple to round down to.

Returns

int

The value rounded down to the nearest multiple of roundTo.