Ray

Ray

A ray for the purposes of computing sight and collision Given points A[x,y] and B[x,y]

Slope-Intercept form: y = a + bx y = A.y + ((B.y - A.Y) / (B.x - A.x))x

Parametric form: R(t) = (1-t)A + tB

Constructor

new Ray()

Source:

Members

angle :number

Source:

The normalized angle of the ray in radians on the range (-PI, PI)

Type:
  • number

distance :number

Source:

The distance of the ray

Type:
  • number

normAngle :number

Source:

Return the value of the angle normalized to the range (0, 2*PI) This is useful for testing whether an angle falls between two others

Type:
  • number

slope :number

Source:

The slope of the ray, dy over dx

Type:
  • number

Methods

intersectSegment()

Source:

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

project(t) → {Object}

Source:

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