Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Math2D

Index

Functions

computeSquaredLineLength

  • computeSquaredLineLength(line: number[]): number
  • Computes the squared length of a line.

    Parameters

    • line: number[]

      An array of that forms a line via [x,y,z,x,y,z,...] tuples.

    Returns number

distSquared

  • distSquared(ax: number, ay: number, bx: number, by: number): number
  • Compute squared distance between two 2D points a and b.

    Parameters

    • ax: number

      Point a.x

    • ay: number

      Point a.y

    • bx: number

      Point b.x

    • by: number

      Point b.y

    Returns number

    Squared distance between the two points

distToSegmentSquared

  • distToSegmentSquared(px: number, py: number, l0x: number, l0y: number, l1x: number, l1y: number): number
  • Compute squared distance between a 2D point and a 2D line segment.

    Parameters

    • px: number

      Test point X

    • py: number

      Test point y

    • l0x: number

      Line segment start X

    • l0y: number

      Line segment start Y

    • l1x: number

      Line segment end X

    • l1y: number

      Line segment end Y

    Returns number

    Squared distance between point and line segment

intersectLineAndCircle

  • intersectLineAndCircle(xLine1: number, yLine1: number, xLine2: number, yLine2: number, radius: number, xCenter?: number, yCenter?: number): { x1: number; x2?: undefined | number; y1: number; y2?: undefined | number } | undefined
  • Finds the intersections of a line and a circle.

    Parameters

    • xLine1: number

      abscissa of first line point.

    • yLine1: number

      ordinate of second line point.

    • xLine2: number

      abscissa of second line point.

    • yLine2: number

      ordinate of second line point.

    • radius: number

      circle radius.

    • Default value xCenter: number = 0

      abscissa of circle center.

    • Default value yCenter: number = 0

      ordinate of circle center.

    Returns { x1: number; x2?: undefined | number; y1: number; y2?: undefined | number } | undefined

    coordinates of the intersections (1 if the line is tangent to the circle, 2 if it's secant) or undefined if there's no intersection.

intersectLines

  • intersectLines(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number, x4: number, y4: number, result?: Vec2Like): Vec2Like | undefined
  • Computes the intersection point between two lines.

    remarks

    This functions computes the line-line intersection of two lines given two points on each line.

    Parameters

    • x1: number

      x coordinate of the first point of the first line.

    • y1: number

      y coordinate of the first point of the first line.

    • x2: number

      x coordinate of the second point of the first line.

    • y2: number

      y coordinate of the second point of the first line.

    • x3: number

      x coordinate of the first point of the second line.

    • y3: number

      y coordinate of the first point of the second line.

    • x4: number

      x coordinate of the second point of the second line.

    • y4: number

      y coordinate of the second point of the second line.

    • Default value result: Vec2Like = { x: 0, y: 0 }

      The resulting point.

    Returns Vec2Like | undefined

Generated using TypeDoc