Table of Contents

Method WrapAroundCenter

Namespace
LMKit.Graphics.Geometry
Assembly
LM-Kit.NET.dll

WrapAroundCenter(double, double)

Wraps an angle (degrees) around an arbitrary center such that the result lies in [-180, 180).

public static double WrapAroundCenter(double deg, double centerDeg)

Parameters

deg double

Angle in degrees.

centerDeg double

Center angle in degrees about which to wrap.

Returns

double

The wrapped angle in the interval [-180, 180), measured relative to centerDeg.

Examples

// Wrap 350° around a center of 0° -> -10°
double w = Angles.WrapAroundCenter(350, 0);   // -10
// Wrap 10° around a center of 350° -> 20°
double w2 = Angles.WrapAroundCenter(10, 350); // 20

Remarks

Useful for circular median/mean computations: unwrap a set of angles relative to their mean, compute a robust statistic in a linear space, then re-wrap to absolute orientation.

See Also