Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Vec2

Vec2 - 2D vector class

Hierarchy

  • Vec2

Index

Constructors

  • new Vec2(x?: number, y?: number): Vec2
  • create a Vector 2D Object

    Parameters

    • x: number = 0
    • y: number = 0

    Returns Vec2

Properties

x: number
y: number

Methods

  • add(other: Object): Vec2
  • Return a new vector sum of this and another

    Parameters

    • other: Object

    Returns Vec2

  • angle(other: Vec2): number
  • Return the angle in radians between two vectors

    Parameters

    Returns number

  • Clone a Vec2

    Returns Vec2

    a fresh Vec2

  • det(__namedParameters: Object): number
  • Return the determinant of this and another vector

    Parameters

    • __namedParameters: Object

    Returns number

  • distance(other: any): number
  • return the distance between this point and another

    Parameters

    • other: any

    Returns number

  • distance2(other: any): number
  • return the squared distance between this point and another

    Parameters

    • other: any

    Returns number

  • div(other: Object): Vec2
  • Return a new vector quotient of this and another

    Parameters

    • other: Object

    Returns Vec2

  • dot(__namedParameters: Object): number
  • Return the dot product of this and another vector

    Parameters

    • __namedParameters: Object

    Returns number

  • equals(__namedParameters: Object): boolean
  • Compare to a vector

    Parameters

    • __namedParameters: Object

    Returns boolean

  • length(): number
  • Return the length/norm/magnitude of this vector

    Returns number

  • length2(): number
  • Return the squared length of this vector

    Returns number

  • lerp(__namedParameters: Object, alpha: any): Vec2
  • Linear interpolation

    Parameters

    • __namedParameters: Object
    • alpha: any

    Returns Vec2

  • mul(other: Object): Vec2
  • Return a new vector product of this and another

    Parameters

    • other: Object

    Returns Vec2

  • Return a new vector of length 1 and of same direction.

    Returns Vec2

  • Set the components of a vector in place

    Parameters

    • x: number | Vec2
    • y: number = null

    Returns Vec2

  • sub(other: Object): Vec2
  • Return a new vector difference of this and another

    Parameters

    • other: Object

    Returns Vec2

  • withNorm(n: number): Vec2
  • Return a new vector of length n and of same direction.

    Parameters

    • n: number

    Returns Vec2

  • copy(__namedParameters: Object): Vec2
  • Return a fresh vector with the same coordinates.

    Parameters

    • __namedParameters: Object

    Returns Vec2

  • from_obj(obj: Record<string, unknown>): Vec2
  • Construct a Vec2 from an arbitrary object

    Parameters

    • obj: Record<string, unknown>

    Returns Vec2

  • Return a fresh null vector

    Returns Vec2

  • scal(x: number): Vec2
  • Construct a Vec2 with both components equal

    Parameters

    • x: number

      value of the components

    Returns Vec2

  • Construct a Vec2 pointing toward x+

    Returns Vec2

  • Construct a Vec2 pointing toward y+

    Returns Vec2

Generated using TypeDoc