Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace vec2

Index

Functions

  • Adds two vec2's

    Parameters

    • out: Vec2

      the receiving vector

    • a: Vec2

      the first operand

    • b: Vec2

      the second operand

    Returns Vec2

    out

  • Creates a new vec2 initialized with values from an existing vector

    Parameters

    • a: Vec2

      vector to clone

    Returns Vec2

    a new 2D vector

  • Copy the values from one vec2 to another

    Parameters

    • out: Vec2

      the receiving vector

    • a: Vec2

      the source vector

    Returns Vec2

    out

  • Creates a new, empty vec2

    Returns Vec2

    a new 2D vector

  • Make a cross product and only return the z component

    Parameters

    Returns number

  • Cross product between a vector and the Z component of a vector

    Parameters

    Returns Vec2

  • Cross product between a vector and the Z component of a vector

    Parameters

    Returns Vec2

  • Calculates the euclidian distance between two vec2's

    Parameters

    • a: Vec2

      the first operand

    • b: Vec2

      the second operand

    Returns number

    distance between a and b

  • Divides two vec2's

    Parameters

    • out: Vec2

      the receiving vector

    • a: Vec2

      the first operand

    • b: Vec2

      the second operand

    Returns Vec2

    out

  • Calculates the dot product of two vec2's

    Parameters

    • a: Vec2

      the first operand

    • b: Vec2

      the second operand

    Returns number

    dot product of a and b

  • fromValues(x: number, y: number): Vec2
  • Creates a new vec2 initialized with the given values

    Parameters

    • x: number

      X component

    • y: number

      Y component

    Returns Vec2

    a new 2D vector

  • Get the intersection point between two line segments.

    Parameters

    Returns boolean

    True if there was an intersection, otherwise false.

  • getLineSegmentsIntersectionFraction(p0: Vec2, p1: Vec2, p2: Vec2, p3: Vec2): number
  • Get the intersection fraction between two line segments. If successful, the intersection is at p0 + t * (p1 - p0)

    Parameters

    Returns number

    A number between 0 and 1 if there was an intersection, otherwise -1.

  • length(a: Vec2): number
  • Calculates the length of a vec2

    Parameters

    • a: Vec2

      vector to calculate length of

    Returns number

    length of a

  • Linearly interpolate/mix two vectors.

    Parameters

    • out: Vec2
    • a: Vec2

      First vector

    • b: Vec2

      Second vector

    • t: number

      Lerp factor

    Returns Vec2

  • Multiplies two vec2's

    Parameters

    • out: Vec2

      the receiving vector

    • a: Vec2

      the first operand

    • b: Vec2

      the second operand

    Returns Vec2

    out

  • Negates the components of a vec2

    Parameters

    • out: Vec2

      the receiving vector

    • a: Vec2

      vector to negate

    Returns Vec2

    out

  • Normalize a vec2

    Parameters

    • out: Vec2

      the receiving vector

    • a: Vec2

      vector to normalize

    Returns Vec2

    out

  • Reflect a vector along a normal.

    Parameters

    Returns Vec2

  • Rotate a vector by an angle

    Parameters

    Returns Vec2

  • Rotate a vector 90 degrees clockwise

    Parameters

    Returns Vec2

  • Scales a vec2 by a scalar number

    Parameters

    • out: Vec2

      the receiving vector

    • a: Vec2

      the vector to scale

    • b: number

      amount to scale the vector by

    Returns Vec2

    out

  • set(out: Vec2, x: number, y: number): Vec2
  • Set the components of a vec2 to the given values

    Parameters

    • out: Vec2

      the receiving vector

    • x: number

      X component

    • y: number

      Y component

    Returns Vec2

    out

  • squaredDistance(a: Vec2, b: Vec2): number
  • Calculates the squared euclidian distance between two vec2's

    Parameters

    • a: Vec2

      the first operand

    • b: Vec2

      the second operand

    Returns number

    squared distance between a and b

  • squaredLength(a: Vec2): number
  • Calculates the squared length of a vec2

    Parameters

    • a: Vec2

      vector to calculate squared length of

    Returns number

    squared length of a

  • str(a: Vec2): string
  • Returns a string representation of a vector

    Parameters

    Returns string

    string representation of the vector

  • Subtracts two vec2's

    Parameters

    • out: Vec2

      the receiving vector

    • a: Vec2

      the first operand

    • b: Vec2

      the second operand

    Returns Vec2

    out

  • toGlobalFrame(out: Vec2, localPoint: Vec2, framePosition: Vec2, frameAngle: number): void
  • Transform a point position to global frame.

    Parameters

    • out: Vec2
    • localPoint: Vec2
    • framePosition: Vec2
    • frameAngle: number

    Returns void

  • toLocalFrame(out: Vec2, worldPoint: Vec2, framePosition: Vec2, frameAngle: number): Vec2
  • Transform a point position to local frame.

    Parameters

    • out: Vec2
    • worldPoint: Vec2
    • framePosition: Vec2
    • frameAngle: number

    Returns Vec2

  • vectorToGlobalFrame(out: Vec2, a: Vec2, angle: number): Vec2
  • Transform a vector to global frame.

    Parameters

    Returns Vec2

  • vectorToLocalFrame(out: Vec2, worldVector: Vec2, frameAngle: number): Vec2
  • Transform a vector to local frame.

    Parameters

    • out: Vec2
    • worldVector: Vec2
    • frameAngle: number

    Returns Vec2