Angle class Null safety

Represents an angle. The unit used for construction does not matter, as angles internally always use radians. The class is designed to be immutable but provides operators like adding or subtracting, which all create new angles instead of mutating existing ones.

Implemented types
Annotations

Constructors

Angle.acos(double c)
Create an angle by computing the arc cosine of c.
Angle.asin(double c)
Create an angle by computing the arc sine of c.
Angle.atan(double c)
Create an angle by computing the arc tangent of c.
Angle.atan2(double y, double x)
Create an angle by computing the arc tangent from y / x. This uses the atan2() function, therefore there are two separate parameters for the nominator and the denominator. The result is an angle in ]-180°;180°]. Sample values:
Angle.atanFullTurn(double y, double x)
Works in the same manner as Angle.atan2, but results in an angle in [0°, 360°). Sample values:
factory
Angle.cartesian(double x, double y)
Returns an angle in [0°, 360°), pointing to the cartesian coordinate. The x axis has angle , the y axis has angle 90°.
factory
Angle.degrees(double degrees)
Create an angle defined by degrees. One full turn equals 360 degrees.
const
Angle.eighthTurn()
Create an angle defining one eighth turn.
factory
Angle.fromDegrees(double degrees)
const
Angle.fromGradians(double gradians)
const
Angle.fromRadians(double radians)
const
Angle.fromTurns(double turns)
const
Angle.fullTurn()
Create an angle defining one full turn.
factory
Angle.gradians(double gradians)
Create an angle defined by gradians. One full turn equals 400 gradians.
const
Angle.halfTurn()
Create an angle defining one half turn.
factory
Angle.quarterTurn()
Create an angle defining one quarter turn.
factory
Angle.radians(double radians)
Create an angle from radians. One full turn equals 2pi radians.
const
Angle.thirdTurn()
Create an angle defining one third turn.
factory
Angle.turns(double turns)
Create an angle defined by turns. One full turn equals 1 turn.
const
Angle.zero()
Create a zero angle.
const

Properties

cos double
Compute the cosine of this angle.
read-only
degrees double
Get the angle in degrees.
read-only
gradians double
Get the angle in gradians.
read-only
hashCode int
The hash code for this object.
read-onlyoverride
normalized Angle
Returns an angle with the some direction, but confined to the interval [0°, 360°).
read-only
radians double
Get the angle in radians.
read-only
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
sin double
Compute the sine of this angle.
read-only
tan double
Compute the tangent of this angle.
read-only
turns double
Get the angle in turns.
read-only

Methods

approximately(Angle rhs, double range) bool
Checks if rhs is approximately this angle, +/- range. range must be non-negative.
compareTo(Angle other) int
Compares this object to another object.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
ratio(Angle other) double
Returns the ratio between two angles.
toString() String
Return a string representation of this angle, optimized to be readable. The angle is printed in degrees, and only one decimal digit is included.
override

Operators

operator *(double scale) Angle
Scale this angle, returning a new angle.
operator +(Angle other) Angle
Accumulate this and other, returning a new angle.
operator -(Angle other) Angle
Compute the difference of this to other, returning a new angle.
operator /(double scale) Angle
Inverse scale this angle, returning a new angle.
operator <(Angle other) bool
Compares this to other.
operator <=(Angle other) bool
Compares this to other.
operator ==(covariant Angle rhs) bool
Compares to another angle. Since IEEE 754 floating points are approximations to real numbers, they cannot be really tested for equality.
override
operator >(Angle other) bool
Compares this to other.
operator >=(Angle other) bool
Compares this to other.
operator unary-() Angle
Negate this angle, returning a new angle.