The origin point, {x, y}
The destination point, {x, y}
The horizontal distance of the ray, x1 - x0
The vertical distance of the ray, y1 - y0
The slope of the ray, dy over dx
The origin x-coordinate
The origin y-coordinate
The normalized angle of the ray in radians on the range (-PI, PI). The angle is computed lazily (only if required) and cached.
A normalized bounding rectangle that encompasses the Ray
The distance (length) of the Ray in pixels. The distance is computed lazily (only if required) and cached.
Find the point I[x,y] and distance t* on ray R(t) which intersects another ray.
An array of four coordinates [x1, y1, x2, y2]
.
The intersection result from foundry.utils.lineSegmentIntersection
or null
if no intersection was found.
Project the Array by some proportion of it's initial distance. Return the coordinates of that point along the path.
The distance along the Ray
The coordinates of the projected point
Reverse the direction of the Ray, returning a second Ray
Create a new ray which uses the same origin point, but a slightly offset angle and distance
An offset in radians which modifies the angle of the original Ray
Optional
distance: numberA distance the new ray should project, otherwise uses the same distance.
A new Ray with an offset angle
Static
fromA factory method to construct a Ray from an origin point, an angle, and a distance
The origin x-coordinate
The origin y-coordinate
The ray angle in radians
The distance of the ray in pixels
The constructed Ray instance
Static
fromA factory method to construct a Ray from points in array format.
The origin point [x,y]
The destination point [x,y]
The constructed Ray instance
Static
towardsCreate a Ray by projecting a certain distance towards a known point.
The origin of the Ray
The point towards which to project
The distance of projection
Static
towardsCreate a Ray by projecting a certain squared-distance towards a known point.
The origin of the Ray
The point towards which to project
The squared distance of projection
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
Param: A
The origin of the Ray
Param: B
The destination of the Ray