SightRay

SightRay

A subclass of Ray that is used specifically for computing source polygons

Constructor

new SightRay()

Extends

Members

A :Point

Inherited From:

The origin point, {x, y}

Type:

angle :number

Inherited From:

The normalized angle of the ray in radians on the range (-PI, PI). The angle is computed lazily (only if required) and cached.

Type:
  • number

B :Point

Inherited From:

The destination point, {x, y}

Type:

bounds :NormalizedRectangle

Inherited From:

A bounding rectangle that encompasses the Ray

Type:

collisions :Array.<WallEndpoint>

The array of sorted collision points which apply for this Ray.

Type:

distance :number

Inherited From:

The distance (length) of the Ray in pixels. The distance is computed lazily (only if required) and cached.

Type:
  • number

dx :number

Inherited From:

The horizontal distance of the ray, x1 - x0

Type:
  • number

dy :number

Inherited From:

The vertical distance of the ray, y1 - y0

Type:
  • number

endpoint :WallEndpoint|null

The target endpoint at which this Ray was fired

Type:

lastCollision :WallEndpoint|null

The final collision point that this SightRay encountered.

Type:

result :object

The result objects which records the outcome of this Ray

Type:
  • object

slope :number

Inherited From:

The slope of the ray, dy over dx

Type:
  • number

x0 :number

Inherited From:

The origin x-coordinate

Type:
  • number

y0 :number

Inherited From:

The origin y-coordinate

Type:
  • number

Methods

intersectSegment(coords) → {RayIntersection|boolean}

Inherited From:

Find the point I[x,y] and distance t* on ray R(t) which intersects another ray http://paulbourke.net/geometry/pointlineplane/

Parameters:
Name Type Description
coords Array.<number>

An array of coordinates [x0, y0, x1, y1] which defines a line segment to test

Returns:

The point of collision [x,y] the position of that collision point along the Ray (t0) an the tested segment (t1). Returns false if no collision occurs.

Type
RayIntersection | boolean

project(t) → {Object}

Inherited From:

Project the Array by some proportion of it's initial distance. Return the coordinates of that point along the path.

Parameters:
Name Type Description
t number

The distance along the Ray

Returns:

The coordinates of the projected point

Type
Object

reverse() → {Ray}

Inherited From:

Reverse the direction of the Ray, returning a second Ray

Returns:
Type
Ray

shiftAngle(offset, distanceopt) → {Ray}

Inherited From:

Create a new ray which uses the same origin point, but a slightly offset angle and distance

Parameters:
Name Type Attributes Description
offset number

An offset in radians which modifies the angle of the original Ray

distance number <optional>

A distance the new ray should project, otherwise uses the same distance.

Returns:

A new Ray with an offset angle

Type
Ray