Class Angles
Angle utilities for conversions, formatting, normalization, and circular distance.
public static class Angles
- Inheritance
-
Angles
- Inherited Members
Remarks
This static helper provides:
- Degree <-> radian conversion for double and float.
- Invariant string formatting helpers for angles (DegText(double), RadText(double)).
- Normalization to the canonical range [0, 360) via Normalize360(double).
- Wrapping around an arbitrary center with range [-180, 180) via WrapAroundCenter(double, double).
- Minimal circular distance on the unit circle via AngDist(double, double) and near-equality with IsNear(double, double, double).
Fields
- Deg2Rad
Constant multiplier to convert degrees to radians: π / 180.
- Rad2Deg
Constant multiplier to convert radians to degrees: 180 / π.
Methods
- AngDist(double, double)
Computes the minimal circular distance between two angles (degrees).
- CircularMeanDegrees(ReadOnlySpan<double>)
Computes the circular mean of a set of angles in degrees.
- CircularMeanDegrees(ReadOnlySpan<double>, ReadOnlySpan<double>)
Computes the weighted circular mean of angles in degrees.
- CircularVariance(ReadOnlySpan<double>)
Computes the circular variance of angles in degrees as
1 - R, whereRis the mean resultant length.
- DegText(double)
Formats an angle in degrees as an invariant string, appending the degree symbol (
°).
- IsNear(double, double, double)
Determines whether two angles in degrees are within a specified inclusive tolerance.
- LerpDegrees(double, double, double)
Linearly interpolates between two angles (degrees) along the shortest arc.
- Normalize180(double)
Normalizes an angle in degrees to the signed range [-180, 180).
- Normalize360(double)
Normalizes an angle in degrees to the canonical range [0, 360).
- NormalizePi(double)
Normalizes an angle in radians to the signed range [-π, π).
- NormalizeTwoPi(double)
Normalizes an angle in radians to the canonical range [0, 2π).
- RadText(double)
Formats an angle in radians as an invariant string, appending the suffix
" rad".
- ResultantLength(ReadOnlySpan<double>)
Computes the mean resultant length (R) of angles in degrees, a concentration measure in [0,1].
- SignedDeltaDegrees(double, double)
Returns the signed smallest angular difference (degrees) from
fromDegtotoDeg.
- SinCosDeg(double, out double, out double)
Computes sine and cosine for a degree input using a single radians conversion.
- SnapDegrees(double, double, double)
Snaps an angle in degrees to the nearest multiple of
stepDeg, with an optional offset.
- ToDeg(double)
Converts an angle in radians to degrees.
- ToDeg(float)
Converts an angle in radians to degrees (single precision).
- ToRad(double)
Converts an angle in degrees to radians.
- ToRad(float)
Converts an angle in degrees to radians (single precision).
- WrapAroundCenter(double, double)
Wraps an angle (degrees) around an arbitrary center such that the result lies in [-180, 180).