a collection of mathematical utility functions used by the chart classes

Constructors

Methods

  • clips a line to the specified bounding rectangle

    Parameters

    • p1x: number
    • p1y: number
    • p2x: number
    • p2y: number
    • rect: Bounds

    Returns false | [x: number, y: number, x2: number, y2: number, shift: number]

  • clips a line to the specified x range

    Parameters

    • p1x: number
    • p1y: number
    • p2x: number
    • p2y: number
    • rx1: number
    • rx2: number

    Returns [number, number, number, number]

  • Parameters

    • points: [number, number][]
    • rect: Bounds

    Returns false | [number, number][]

  • calculates the convex hull of a set of points (using the gift wrapping algorithm)

    Type Parameters

    • HullPoint extends { x: number; y: number }

    Parameters

    Returns HullPoint[]

  • calculates the intersection point of two lines

    Parameters

    • x1: number
    • y1: number
    • x2: number
    • y2: number
    • x3: number
    • y3: number
    • x4: number
    • y4: number

    Returns { x: number; y: number }

  • checks if a line (x1,y1)->(x2,y2) intersects with another line (x3,y3)->(x4,y4) from: https://stackoverflow.com/a/24392281

    Parameters

    • x1: number
    • y1: number
    • x2: number
    • y2: number
    • x3: number
    • y3: number
    • x4: number
    • y4: number

    Returns boolean

  • determines if a point resides inside of a polygon

    Parameters

    • x: number
    • y: number
    • points: { x: number; y: number }[]

    Returns boolean

  • checks if the specified point lies within the provided bounding rectangle

    Parameters

    • x: number
    • y: number
    • rect: Bounds | { right: number; top: number; x: number; y: number }

    Returns boolean

  • checks if a point lies on (or is near, depending on range parameter) a line segment

    Parameters

    • x0: number

      x coordinate of point

    • y0: number

      y coordinate of point

    • x1: number

      x coordinate of first line point

    • y1: number

      y coordinate of first line point

    • x2: number

      x coordinate of second line point

    • y2: number

      y coordinate of second line point

    • range: number

      maximum allowed distance to the line

    Returns boolean

  • checks if two rectangles intersect

    Type Parameters

    • Rectangle extends { right: number; top: number; x: number; y: number }

    Parameters

    Returns boolean