Table of Contents

Interface IAngleCalculator<T>

Namespace
Utils.Mathematics
Assembly
Utils.dll

Provides an interface for angle-based calculations in various units (Radians, Degrees, Grades). Includes standard and extended trigonometric, hyperbolic, and inverse functions.

public interface IAngleCalculator<T> where T : struct, IFloatingPointIeee754<T>

Type Parameters

T

A floating-point numeric type (e.g., float, double) implementing IFloatingPointIeee754<TSelf>.

Extension Methods

Properties

Graduation

Represents the conversion factor to radians. For non-radian systems, use this to convert angles to radians and call standard .NET trig methods.

T Graduation { get; }

Property Value

T

Perigon

Represents the full rotation (perigon) in this angle system. For example, 360 in degrees, 2π in radians, 400 in grads.

T Perigon { get; }

Property Value

T

RightAngle

Represents a right angle (one-quarter of Perigon). For example, 90 in degrees, π/2 in radians, 100 in grads.

T RightAngle { get; }

Property Value

T

StraightAngle

Represents a straight angle (half of Perigon). For example, 180 in degrees, π in radians, 200 in grads.

T StraightAngle { get; }

Property Value

T

Methods

Acos(T)

Computes the arccosine of the specified value and returns the corresponding angle in the current measurement system.

T Acos(T value)

Parameters

value T

The cosine ratio whose angle should be determined.

Returns

T

An angle whose cosine is value.

Acosh(T)

Computes the inverse hyperbolic cosine of the specified value.

T Acosh(T value)

Parameters

value T

The hyperbolic cosine ratio whose angle should be determined.

Returns

T

An angle whose hyperbolic cosine is value.

Acot(T)

Computes the arccotangent of the specified value and returns the corresponding angle in the current measurement system.

T Acot(T value)

Parameters

value T

The cotangent ratio whose angle should be determined.

Returns

T

An angle whose cotangent is value.

Acot2(T, T)

Analogous to Atan2(T, T) but for the cotangent. Internally computed as atan2(y, x).

T Acot2(T x, T y)

Parameters

x T
y T

Returns

T

Acoth(T)

Computes the inverse hyperbolic cotangent of the specified value.

T Acoth(T value)

Parameters

value T

The hyperbolic cotangent ratio whose angle should be determined.

Returns

T

An angle whose hyperbolic cotangent is value.

Acsc(T)

Computes the arccosecant of the specified value and returns the corresponding angle in the current measurement system.

T Acsc(T value)

Parameters

value T

The cosecant ratio whose angle should be determined.

Returns

T

An angle whose cosecant is value.

Acsch(T)

Computes the inverse hyperbolic cosecant of the specified value.

T Acsch(T value)

Parameters

value T

The hyperbolic cosecant ratio whose angle should be determined.

Returns

T

An angle whose hyperbolic cosecant is value.

AddAngles(T, T)

Adds two angles in this system, wrapping around if the sum exceeds Perigon.

T AddAngles(T angle1, T angle2)

Parameters

angle1 T
angle2 T

Returns

T

AreEqual(T, T, T)

Determines whether two angles are equal within the specified tolerance, treating the angle system as circular: e.g. in degrees, 359.999999 and 0.000001 are almost equal (shortest distance 0.000002), not ~360 apart as a naive |a - b| would suggest.

bool AreEqual(T angle1, T angle2, T tolerance)

Parameters

angle1 T

First angle, expressed in this calculator's measurement system.

angle2 T

Second angle, expressed in this calculator's measurement system.

tolerance T

Maximum allowed angular distance between the two angles.

Returns

bool

true if the shortest angular distance between angle1 and angle2 is at most tolerance; otherwise false.

AreEqualRounded(T, T, int)

Determines whether two angles round to the same value at the given decimal precision, after normalizing both to [0, Perigon) so that wraparound values (e.g. in degrees, 359.999999 and -0.000001) are compared consistently instead of as if they were ~360 apart.

bool AreEqualRounded(T angle1, T angle2, int decimals)

Parameters

angle1 T

First angle, expressed in this calculator's measurement system.

angle2 T

Second angle, expressed in this calculator's measurement system.

decimals int

Number of decimal places to round to before comparing.

Returns

bool

true if angle1 and angle2 round to the same normalized value; otherwise false.

Asec(T)

Computes the arcsecant of the specified value and returns the corresponding angle in the current measurement system.

T Asec(T value)

Parameters

value T

The secant ratio whose angle should be determined.

Returns

T

An angle whose secant is value.

Asech(T)

Computes the inverse hyperbolic secant of the specified value.

T Asech(T value)

Parameters

value T

The hyperbolic secant ratio whose angle should be determined.

Returns

T

An angle whose hyperbolic secant is value.

Asin(T)

Computes the arcsine of the specified value and returns the corresponding angle in the current measurement system.

T Asin(T value)

Parameters

value T

The sine ratio whose angle should be determined.

Returns

T

An angle whose sine is value.

Asinh(T)

Computes the inverse hyperbolic sine of the specified value.

T Asinh(T value)

Parameters

value T

The hyperbolic sine ratio whose angle should be determined.

Returns

T

An angle whose hyperbolic sine is value.

Atan(T)

Computes the arctangent of the specified value and returns the corresponding angle in the current measurement system.

T Atan(T value)

Parameters

value T

The tangent ratio whose angle should be determined.

Returns

T

An angle whose tangent is value.

Atan2(T, T)

Computes the four-quadrant inverse tangent of x/y, returning an angle in the range [-StraightAngle, StraightAngle]. This is analogous to atan2(x, y) in standard math libraries.

T Atan2(T x, T y)

Parameters

x T
y T

Returns

T

Atanh(T)

Computes the inverse hyperbolic tangent of the specified value.

T Atanh(T value)

Parameters

value T

The hyperbolic tangent ratio whose angle should be determined.

Returns

T

An angle whose hyperbolic tangent is value.

Cos(T)

Computes the cosine of the supplied angle measured in the current angle system.

T Cos(T angle)

Parameters

angle T

Angle expressed in this calculator's measurement system.

Returns

T

The cosine of angle.

Cosh(T)

Computes the hyperbolic cosine of the supplied angle.

T Cosh(T angle)

Parameters

angle T

Angle expressed in this calculator's measurement system.

Returns

T

The hyperbolic cosine of angle.

Cot(T)

Computes the cotangent of the supplied angle measured in the current angle system.

T Cot(T angle)

Parameters

angle T

Angle expressed in this calculator's measurement system.

Returns

T

The cotangent of angle.

Coth(T)

Computes the hyperbolic cotangent of the supplied angle.

T Coth(T angle)

Parameters

angle T

Angle expressed in this calculator's measurement system.

Returns

T

The hyperbolic cotangent of angle.

Csc(T)

Computes the cosecant of the supplied angle measured in the current angle system.

T Csc(T angle)

Parameters

angle T

Angle expressed in this calculator's measurement system.

Returns

T

The cosecant of angle.

Csch(T)

Computes the hyperbolic cosecant of the supplied angle.

T Csch(T angle)

Parameters

angle T

Angle expressed in this calculator's measurement system.

Returns

T

The hyperbolic cosecant of angle.

FromRadian(T)

Converts an angle from radians into the current measurement system.

T FromRadian(T angle)

Parameters

angle T

Returns

T

Normalize0To2Max(T)

Normalizes an angle into the range [0, Perigon), i.e., 0..360 for degrees, 0..2π for radians, 0..400 for grads.

T Normalize0To2Max(T angle)

Parameters

angle T

Returns

T

NormalizeMinToMax(T)

Normalizes an angle into the range [ -StraightAngle, +StraightAngle ), i.e., -180..180 for degrees, -π..π for radians, -200..200 for grads.

T NormalizeMinToMax(T angle)

Parameters

angle T

Returns

T

NormalizeRounded(T, int)

Normalizes angle to [0, Perigon) and rounds it to decimals decimal places, wrapping a result that rounds up to exactly Perigon back to zero. This is the canonical value AreEqualRounded(T, T, int) compares internally; expose it separately so callers needing a hash-consistent representative value (rather than a yes/no comparison) don't have to reimplement the wraparound handling.

T NormalizeRounded(T angle, int decimals)

Parameters

angle T

The angle to normalize and round, expressed in this calculator's measurement system.

decimals int

Number of decimal places to round to.

Returns

T

The normalized, rounded angle, always in [0, Perigon).

Sec(T)

Computes the secant of the supplied angle measured in the current angle system.

T Sec(T angle)

Parameters

angle T

Angle expressed in this calculator's measurement system.

Returns

T

The secant of angle.

Sech(T)

Computes the hyperbolic secant of the supplied angle.

T Sech(T angle)

Parameters

angle T

Angle expressed in this calculator's measurement system.

Returns

T

The hyperbolic secant of angle.

Sin(T)

Computes the sine of the supplied angle measured in the current angle system.

T Sin(T angle)

Parameters

angle T

Angle expressed in this calculator's measurement system.

Returns

T

The sine of angle.

Sinh(T)

Computes the hyperbolic sine of the supplied angle.

T Sinh(T angle)

Parameters

angle T

Angle expressed in this calculator's measurement system.

Returns

T

The hyperbolic sine of angle.

SubtractAngles(T, T)

Subtracts angle2 from angle1 in this system, wrapping around if the result is negative or above Perigon.

T SubtractAngles(T angle1, T angle2)

Parameters

angle1 T
angle2 T

Returns

T

Tan(T)

Computes the tangent of the supplied angle measured in the current angle system.

T Tan(T angle)

Parameters

angle T

Angle expressed in this calculator's measurement system.

Returns

T

The tangent of angle.

Tanh(T)

Computes the hyperbolic tangent of the supplied angle.

T Tanh(T angle)

Parameters

angle T

Angle expressed in this calculator's measurement system.

Returns

T

The hyperbolic tangent of angle.

ToRadian(T)

Converts an angle to radians from the current measurement system.

T ToRadian(T angle)

Parameters

angle T

Returns

T