Table of Contents

Struct Angle

Namespace
EncDotNet.S100.Quantities
Assembly
EncDotNet.S100.Core.dll

A planar angle, stored canonically in degrees.

public readonly record struct Angle : IComparable<Angle>, IEquatable<Angle>
Implements
Inherited Members

Remarks

Angle models directions and rotations — most commonly marine bearings measured clockwise from true north — without committing callers to degrees or radians at the API boundary. Values are created through FromDegrees(double)/FromRadians(double) and read back through TotalDegrees/TotalRadians.

The type follows the same readonly record struct design as Length: value semantics, arithmetic operators, and ordering. Stored angles are not implicitly normalized; call Normalized() to fold a value into the [0, 360) degree range used for bearings.

Because the backing store is a double, equality (==) is exact floating-point equality. Prefer CompareTo(Angle) with a tolerance when comparing computed values.

Fields

DegreesPerRadian

Degrees per radian (180 / π).

public const double DegreesPerRadian = 57.29577951308232

Field Value

double

DegreesPerTurn

Degrees in a full turn.

public const double DegreesPerTurn = 360

Field Value

double

Properties

TotalDegrees

The angle expressed in degrees (the canonical unit).

public double TotalDegrees { get; }

Property Value

double

TotalRadians

The angle expressed in radians.

public double TotalRadians { get; }

Property Value

double

Zero

A zero angle. Equal to default(Angle).

public static Angle Zero { get; }

Property Value

Angle

Methods

CompareTo(Angle)

Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.

public int CompareTo(Angle other)

Parameters

other Angle

An object to compare with this instance.

Returns

int

A value that indicates the relative order of the objects being compared. The return value has these meanings:

Value Meaning
Less than zero This instance precedes other in the sort order.
Zero This instance occurs in the same position in the sort order as other.
Greater than zero This instance follows other in the sort order.

FromDegrees(double)

Creates an angle from a value in degrees.

public static Angle FromDegrees(double degrees)

Parameters

degrees double

Returns

Angle

FromRadians(double)

Creates an angle from a value in radians.

public static Angle FromRadians(double radians)

Parameters

radians double

Returns

Angle

Normalized()

Returns an equivalent angle folded into the [0, 360) degree range (the convention for compass bearings).

public Angle Normalized()

Returns

Angle

ToString()

Returns an invariant-culture string of the form "90°" for diagnostic purposes. User-facing presentation should go through a dedicated formatter.

public override string ToString()

Returns

string

Operators

operator +(Angle, Angle)

Adds two angles.

public static Angle operator +(Angle a, Angle b)

Parameters

a Angle
b Angle

Returns

Angle

operator /(Angle, double)

Divides an angle by a dimensionless divisor.

public static Angle operator /(Angle a, double divisor)

Parameters

a Angle
divisor double

Returns

Angle

operator >(Angle, Angle)

Indicates whether one angle is greater than another.

public static bool operator >(Angle a, Angle b)

Parameters

a Angle
b Angle

Returns

bool

operator >=(Angle, Angle)

Indicates whether one angle is greater than or equal to another.

public static bool operator >=(Angle a, Angle b)

Parameters

a Angle
b Angle

Returns

bool

operator <(Angle, Angle)

Indicates whether one angle is less than another.

public static bool operator <(Angle a, Angle b)

Parameters

a Angle
b Angle

Returns

bool

operator <=(Angle, Angle)

Indicates whether one angle is less than or equal to another.

public static bool operator <=(Angle a, Angle b)

Parameters

a Angle
b Angle

Returns

bool

operator *(Angle, double)

Scales an angle by a dimensionless factor.

public static Angle operator *(Angle a, double factor)

Parameters

a Angle
factor double

Returns

Angle

operator *(double, Angle)

Scales an angle by a dimensionless factor.

public static Angle operator *(double factor, Angle a)

Parameters

factor double
a Angle

Returns

Angle

operator -(Angle, Angle)

Subtracts one angle from another.

public static Angle operator -(Angle a, Angle b)

Parameters

a Angle
b Angle

Returns

Angle

operator -(Angle)

Negates an angle.

public static Angle operator -(Angle a)

Parameters

a Angle

Returns

Angle