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
Inheritance
Available extensions

Values

first → const Octant

The first octant, from to 45°.

second → const Octant

The second octant, from 45° to 90°.

third → const Octant

The third octant, from 90° to 135°.

fourth → const Octant

The fourth octant, from 135° to 180°.

fifth → const Octant

The fifth octant, from 180° to 225°.

sixth → const Octant

The sixth octant, from 225° to 270°.

seventh → const Octant

The seventh octant, from 270° to 315°.

eighth → const Octant

The eighth octant, from 315° to 360°.

Properties

hashCode int
The hash code for this object.
no setterinherited
index int
A numeric identifier for the enumerated value.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

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

Constants

values → const List<Octant>
A constant List of the values in this enum, in order of their declaration.