Options
All
  • Public
  • Public/Protected
  • All
Menu

Pure functions and variable definitions to aid in mathy calculations.

Hierarchy

  • MathHelper

Index

Constructors

constructor

Properties

Static Readonly CIRCLE

CIRCLE: number = ...

Distance from start to end in the unit circle

Static Readonly EAST

EAST: 0 = 0

Static Readonly EIGHTH_OF_CIRCLE

EIGHTH_OF_CIRCLE: number = ...

Eighth of a circle, helpful for calculating viewing angle

Static Readonly NORTH

NORTH: number = ...

Pre-Calculated N-W-S-E directions in radiants. Why is that? Because our coordinate system x-axis grows to the right, thus is 0 degrees at that point, visually EAST. The y-axis grows downwards. So from that we deducted the following 4 directions.

Static Readonly SOUTH

SOUTH: number = ...

Static Readonly WEST

WEST: number = ...

Methods

Static euclideanDistance

  • euclideanDistance(pos1: Vec2D, pos2: Vec2D): number

Static signedAngleBetween

  • signedAngleBetween(from: number, to: number): number
  • Calculates the angle difference between two angles. Kind of like a pizza slice.

    Parameters

    • from: number

      angle in radians on the left

    • to: number

      angle in radians on the right

    Returns number

Static vectorInViewCheck

  • vectorInViewCheck(origin: Vec2D, direction: number, target: Vec2D, eyeFov: number): number | boolean
  • Check whether a Point (Vector) is within view and get the angle from our viewpoint.

    Parameters

    • origin: Vec2D

      The viewpoint from which we're looking at the target at, usually the player

    • direction: number

      Direction in radians (0-2pi) which we're looking in

    • target: Vec2D

      The target which we want to check IF we're looking at

    • eyeFov: number

      The field of view OF ONE EYE. This represents HALF THE FOV of the screen

    Returns number | boolean

    Boolean === False IF target is not in view ELSE the angle between origin and target

Generated using TypeDoc