Octant enum
An arc of a circle equal to one-eigth of its circumference.
The octants are arranged as follows, with the origin (0, 0)
at the center
of the diagram, where the x-axis and y-axis intersect; each quadrant is
further divided into two octants, resulting in a total of eight setions, and
numbered counter-clockwise from the top-right corner (1
):
^ y-axis
\ 3 | 2 /
\ | /
4 \|/ 1
-------------+ x-axis
5 /|\ 8
/ | \
/ 6 | 7 \
See also en.wikipedia.org/wiki/Circular_sector.
Usage
This class is provided as a utility for converting points between octants, which is useful when designing algorithms that operate on a 2D coordinate system, such as pathfinding or line-of-sight calculations. For example, it's common to convert a point from it's current octant to the first octant to simplify calculations, and then convert it back to the original octant when the result is needed.
Examples
final octant = Octant.from(Pos(0, 0), Pos(2, 2));
print(octant); // Octant.first
Values
- first → const Octant
-
The first octant, from
0°
to45°
. - second → const Octant
-
The second octant, from
45°
to90°
. - third → const Octant
-
The third octant, from
90°
to135°
. - fourth → const Octant
-
The fourth octant, from
135°
to180°
. - fifth → const Octant
-
The fifth octant, from
180°
to225°
. - sixth → const Octant
-
The sixth octant, from
225°
to270°
. - seventh → const Octant
-
The seventh octant, from
270°
to315°
. - eighth → const Octant
-
The eighth octant, from
315°
to360°
.
Properties
Methods
-
fromOctant1(
Pos position) → Pos -
Converts the provided
position
from the octant's equivalent. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toOctant1(
Pos position) → Pos -
Converts the provided
position
to the octant's equivalent. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited