Angle Struct
Represents an angle value, expressed in degrees or radians.
[TypeConverter(typeof(AngleTypeConverter))]
public readonly struct Angle : IEquatable<Angle>
- Implements:
- IEquatable<Angle>
Properties
Degrees
The angle value, expressed in degrees.
Radians
The angle value, expressed in degrees.
Methods
Equals(Angle)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(Angle other)
Parameter | Type | Description |
---|---|---|
other | Angle | An object to compare with this object. |
Returns
- bool:
true
if the current object is equal to theother
parameter; otherwise,false
.
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameter | Type | Description |
---|---|---|
obj | object | The object to compare with the current instance. |
Returns
- bool:
true
ifobj
and this instance are the same type and represent the same value; otherwise,false
.
FromDegrees(double)
Creates a Angle instance from the specified angle value, expressed in degrees.
public static Angle FromDegrees(double degrees)
Parameter | Type | Description |
---|---|---|
degrees | double | The angle value, expressed in degrees. |
Returns
FromRadians(double)
Creates a Angle instance from the specified angle value, expressed in radians.
public static Angle FromRadians(double radians)
Parameter | Type | Description |
---|---|---|
radians | double | The angle value, expressed in radians. |
Returns
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int:
A 32-bit signed integer that is the hash code for this instance.
Normalize()
Normalizes the angle, creating a new instance when normalization is necessary.
public Angle Normalize()
Returns
- Angle:
The normalized angle.
Remarks
Angle values higher than 360.0
degrees will wrap back to zero (e.g. 540.0
becomes 180.0
).
A negative degree angle will be translated to its positive equivalent (e.g. -90.0
becomes 270.0
).
ToString()
Returns the string representation of this object.
Operators
operator ==(Angle, Angle)
Compares two objects for equality.
public static bool operator ==(Angle left, Angle right)
Parameter | Type | Description |
---|---|---|
left | Angle | The first object to compare. |
right | Angle | The second object to compare. |
Returns
- bool:
true
if the two objects are equal; otherwise,false
.
operator !=(Angle, Angle)
Compares two objects for inequality.
public static bool operator !=(Angle left, Angle right)
Parameter | Type | Description |
---|---|---|
left | Angle | The first object to compare. |
right | Angle | The second object to compare. |
Returns
- bool:
true
if the two objects are not equal; otherwise,false
.