Options
All
  • Public
  • Public/Protected
  • All
Menu

Cao-Math

Simple linear algebra and Hexagonal grid implementations to help the Cao-Lo project.

Repository

Install

npm install --save @caolo-game/cao-math

Index

Functions

_start

  • _start(): void
  • Initialize the global state of the library.

    Users should not have to call this method.

    Returns void

axialToCube

  • Converts a point on the hex grid from axial representation to cube representation

    Parameters

    Returns Vec3f

axialToPixelMatrixFlat

  • axialToPixelMatrixFlat(): Mat2f
  • Calculate the pixel position of the hex point represented by axial coordinates by using rightProd. Assumes "flat top grid".

    Returns Mat2f

axialToPixelMatrixPointy

  • axialToPixelMatrixPointy(): Mat2f
  • Calculate the pixel position of the hex point represented by axial coordinates by using rightProd. Assumes "pointy top grid".

    Returns Mat2f

cubeDistance

  • 'Manhatten-esque' distance between two 'cube' points on the hex grid

    Parameters

    Returns number

cubeSegmentPoints

  • Return a list of points, each point will be inside a hex that is intersected by the segment between points a and b, skipping a and b.

    Parameters

    Returns Array3f

cubeToAxial

  • Converts a point on the hex grid from cube representation to axial representation

    Parameters

    Returns Vec2f

pixelToAxialMatrixFlat

  • pixelToAxialMatrixFlat(): Mat2f
  • Calculate the axial hex grid position of the pixel by using rightProd. Assumes "flat top grid".

    Returns Mat2f

pixelToAxialMatrixPointy

  • pixelToAxialMatrixPointy(): Mat2f
  • Calculate the axial hex grid position of the pixel by using rightProd. Assumes "pointy top grid".

    Returns Mat2f

roundToNearestAxial

  • roundToNearestAxial(q: number, r: number): Vec2f
  • Parameters

    • q: number
    • r: number

    Returns Vec2f

Legend

  • Constructor
  • Property
  • Method
  • Static method

Generated using TypeDoc