Class Box represents bounding box of the shape. It may also represent axis-aligned rectangle

Hierarchy (view full)

Constructors

  • Parameters

    • xmin: number = Number.POSITIVE_INFINITY

      minimal x coordinate

    • ymin: number = Number.POSITIVE_INFINITY

      minimal y coordinate

    • xmax: number = Number.NEGATIVE_INFINITY

      maximal x coordinate

    • ymax: number = Number.NEGATIVE_INFINITY

      maximal y coordinate

    Returns Box

Properties

xmax: number

Maximal x coordinate

xmin: number

Minimal x coordinate

ymax: number

Maximal y coordinate

ymin: number

Minimal y coordinate

Accessors

  • get box(): Box
  • Return property box like all other shapes

    Returns Box

    box itself

  • get center(): Point
  • Return center of the box

    Returns Point

    center point

  • get height(): number
  • Return the height of the box

    Returns number

    height

  • get high(): Point
  • Property high need for interval tree interface

    Returns Point

    right high corner of the box

  • get low(): Point
  • Property low need for interval tree interface

    Returns Point

    left low corner of the box

  • get max(): Box
  • Property max returns the box itself !

    Returns Box

  • get name(): string
  • Shape name

    Returns string

    name of the shape

  • get width(): number
  • Return the width of the box

    Returns number

    width

Methods

  • Return new cloned instance of box

    Returns Box

  • Check if box contains shape: no point of shape lies outside the box

    Parameters

    • shape: Shape<any>

      test shape

    Returns boolean

    true if shape is contained, false otherwise

  • Get distance to shape.

    Parameters

    Returns [number, Segment]

  • Returns true if this box is equal to other box, false otherwise

    Parameters

    • otherBox: Box

      query box

    Returns boolean

    true if equal, false otherwise

  • Check whether the box is intersected with other box

    Parameters

    • otherBox: Box

      Query box

    Returns boolean

    true if intersected with other box

  • Defines predicate "less than" between two boxes. Need for interval index

    Parameters

    • otherBox: Box

      other box

    Returns boolean

    true if this box less than other box, false otherwise

  • Returns new box merged with other box

    Parameters

    • otherBox: Box

      Other box to merge with

    Returns Box

    merged box

  • Check whether the box is intersected with other box

    Parameters

    • otherBox: Box

      other box to test

    Returns boolean

    true if not intersected with other box

  • Box rotation is not supported Attempt to rotate box throws error

    Parameters

    • _angle: number

      in radians

    • _center: Point

    Returns Box

  • Scale shape with coordinates multiplied by scaling factor

    Parameters

    • sx: number

      x-axis scaling factor

    • sy: number

      y-axis scaling factor

    Returns Box

    new scaled shape

  • Set new values to the box object

    Parameters

    • xmin: number = Number.POSITIVE_INFINITY
    • ymin: number = Number.POSITIVE_INFINITY
    • xmax: number = Number.NEGATIVE_INFINITY
    • ymax: number = Number.NEGATIVE_INFINITY

    Returns void

  • Transform box into array of points from low left corner in counterclockwise

    Returns Point[]

  • Transform box into array of segments from low left corner in counterclockwise

    Returns Segment[]

  • Return new box transformed using affine transformation matrix New box is a bounding box of transformed corner points

    Parameters

    • m: Matrix = ...

      affine transformation matrix

    Returns Box

    transformed box

  • Translated shape by given vector. Translation vector may be also defined by a pair of numbers.

    Parameters

    • Rest...args: [number, number] | [Vector]

      Translation vector or translation by x and y or tuple of numbers

    Returns Box

    new translated shape

  • Parameters

    Returns boolean

  • Parameters

    Returns Box