Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "direction"

Index

Type aliases

CardinalDirection

CardinalDirection: North | East | South | West

The four points on a compass.

Direction

A cardinal or intercardinal direction.

East

East: "east"

IntercardinalDirection

IntercardinalDirection: NorthEast | NorthWest | SouthEast | SouthWest

The directions between the cardinal directions.

North

North: "north"

NorthEast

NorthEast: "north-east"

NorthWest

NorthWest: "north-west"

South

South: "south"

SouthEast

SouthEast: "south-east"

SouthWest

SouthWest: "south-west"

West

West: "west"

Cardinal Variables

Const EAST

EAST: East = "east"

Const NORTH

NORTH: North = "north"

Const SOUTH

SOUTH: South = "south"

Const WEST

WEST: West = "west"

Intercardinal Variables

Const NORTH_EAST

NORTH_EAST: NorthEast = "north-east"

Const NORTH_WEST

NORTH_WEST: NorthWest = "north-west"

Const SOUTH_EAST

SOUTH_EAST: SouthEast = "south-east"

Const SOUTH_WEST

SOUTH_WEST: SouthWest = "south-west"

Other Variables

Const CARDINAL_DIRECTIONS

CARDINAL_DIRECTIONS: CardinalDirection[] = [NORTH, EAST, SOUTH, WEST]

Const DIRECTIONS

DIRECTIONS: Direction[] = [NORTH, NORTH_EAST, EAST, SOUTH_EAST, SOUTH, SOUTH_WEST, WEST, NORTH_WEST]

Const INTERCARDINAL_DIRECTIONS

INTERCARDINAL_DIRECTIONS: IntercardinalDirection[] = [NORTH_EAST, SOUTH_EAST, SOUTH_WEST, NORTH_WEST]

Angle Functions

cardinalFromAngle

  • Calculates the approximate CardinalDirection from an angle in radians.

    If you want to find the nearest direction of any type, use fromAngle.

    Direction.fromAngle(0) // Direction.NORTH
    Direction.fromAngle(Math.PI) // Direction.SOUTH

    Parameters

    • radians: number

      Angle in radians

    Returns CardinalDirection

    Approximate cardinal direction

fromAngle

  • Calculates the approximate direction from an angle in radians.

    Direction.fromAngle(0) // Direction.NORTH
    Direction.fromAngle(Math.PI) // Direction.SOUTH

    Parameters

    • radians: number

      Angle in radians

    Returns Direction

    Approximate direction

toAngle

  • Calculates the angle of a given direction.

    Direction.toAngle(Direction.NORTH) // 0
    Direction.toAngle(Direction.SOUTH) // Math.PI

    Parameters

    Returns number

    Angle in radians

Rotation Functions

rotate180

rotateLeft45

rotateLeft90

rotateRight45

rotateRight90

Vector Functions

cardinalFromVector

  • Returns the approximate cardinal direction of a vector.

    Parameters

    Returns CardinalDirection

fromVector

  • Returns the approximate direction from a vector.

    Parameters

    Returns Direction

toVector

  • Creates a unit vector from a direction.

    Parameters

    Returns Vector

Generated using TypeDoc