Class representing a ray (a half-infinite line).

Hierarchy (view full)

Constructors

  • Ray may be constructed by setting an origin point and a normal vector, so that any point x on a ray fit an equation:
    (x - origin) * vector = 0
    Ray defined by constructor is a right semi-infinite line with respect to the normal vector
    If normal vector is omitted ray is considered horizontal (normal vector is (0,1)).
    Don't be confused: direction of the normal vector is orthogonal to the ray

    Parameters

    Returns Ray

Properties

norm: Vector = ...

Normal vector

pt: Point = ...

Start point

Accessors

  • get box(): Box
  • Returns half-infinite bounding box of the ray

    Returns Box

    Bounding box

  • get end(): undefined
  • Ray has no end point?

    Returns undefined

  • get length(): number
  • Return positive infinity number as length

    Returns number

  • get name(): string
  • Shape name

    Returns string

    name of the shape

  • get slope(): number
  • Slope of the ray - angle in radians between ray and axe x from 0 to 2PI

    Returns number

    slope of the line

  • get start(): Point
  • Return ray start point

    Returns Point

    Ray start point

Methods

  • Return new cloned instance of ray

    Returns Ray

  • Returns true if point belongs to ray

    Parameters

    Returns boolean

  • Get distance to shape.

    Parameters

    Returns [number, Segment]

  • Returns array of intersection points between ray and another shape

    Parameters

    • shape: Shape<any>

      Shape to intersect with ray

    Returns Point[]

    array of intersection points

  • Return new line rotated by angle

    Parameters

    • angle: number

      angle in radians

    • center: Point = ...

      center of rotation

    Returns Ray

  • Scale shape with coordinates multiplied by scaling factor

    Parameters

    • sx: number

      x-axis scaling factor

    • sy: number

      y-axis scaling factor

    Returns Ray

    new scaled shape

  • Split ray with point and return array of segment and new ray

    Parameters

    Returns [] | [Segment, Ray] | [Ray]

    [Segment,Ray]

  • Return new ray transformed by affine transformation matrix

    Parameters

    • m: Matrix

      affine transformation matrix (a,b,c,d,tx,ty)

    Returns Ray

  • 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 Ray

    new translated shape