Options
All
  • Public
  • Public/Protected
  • All
Menu

A class for points in arbitary dimensions. Meant for Euclidean space, though hyperbolic space may be eventually implemented.

Hierarchy

  • Point

Index

Constructors

constructor

  • new Point(x: number[] | number): Point
  • Constructor for the Point class.

    Parameters

    • x: number[] | number

      Either the number of dimensions of the point, or its coordinate array.

    Returns Point

Properties

coordinates

coordinates: number[]

Methods

add

  • Adds the coordinates of P to the coordinates of this. Both need to have the same amount of dimensions.

    throws

    Will throw an error if the added point does not have the same number of dimensions.

    Parameters

    Returns Point

    The point this, but with the modified coordinates.

addCoordinate

  • addCoordinate(coord: number): Point
  • Adds a given coordinate to the end of the coordinate list.

    Parameters

    • coord: number

      The coordinate to be added.

    Returns Point

    The modified point.

applyMatrix

  • applyMatrix(matrix: MathJS.Matrix): Point
  • Multiplies a matrix by the vector defined by the point.

    Parameters

    • matrix: MathJS.Matrix

      The rotation matrix to apply to the point.

    Returns Point

    The resulting point.

clone

dimensions

  • dimensions(): number
  • Returns the number of dimensions of the point's space.

    Returns number

    The number of coordinates of the point.

dot

magnitude

  • magnitude(): number

project

scale

  • Scales up this by a factor of r. Simple scalar multiplication.

    Parameters

    • r: number

      The scaling factor.

    Returns Point

    The point this, but scaled.

sqMagnitude

  • sqMagnitude(): number

subtract

  • Subtracts the coordinates of P from the coordinates of this. Both need to have the same amount of dimensions.

    throws

    Will throw an error if the subtracted point does not have the same number of dimensions.

    Parameters

    Returns Point

    The point this, but with the modified coordinates.

toVector3

  • toVector3(): Vector3
  • Converts a point to the Vector3 class used by three.js. Meant only for 3D points – simply copies the coordinates over.

    Returns Vector3

    The Vector3 with the same coordinates as the point.

Static equal

  • Checks if two points are equal, to a predetermined precision.

    Parameters

    • a: Point

      The first point to compare.

    • b: Point

      The second point to compare.

    Returns boolean

    Whether the respective coordinates are "similar enough" by floating point standards.

Static padLeft

  • Pads a point's coordinates with zeros to the left.

    Parameters

    • P: Point

      The point to be padded.

    • n: number

      The number of added zeros.

    Returns Point

    The padded point.

Static padRight

  • Pads a point's coordinates with zeros to the right.

    Parameters

    • P: Point

      The point to be padded.

    • n: number

      The number of added zeros.

    Returns Point

    The padded point.

Static product

  • Takes the Cartesian product of two points. Simply concatenates the coordinates of both points.

    Parameters

    • P: Point

      The first point to multiply.

    • Q: Point

      The second point to multiply.

    Returns Point

    The product of both points.

Generated using TypeDoc, the 1/31/2021 at 6:18:55 AM