Constructor
new Ray(pt, norm)
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
(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
- Source:
Parameters:
Name | Type | Description |
---|---|---|
pt |
Point
|
start point |
norm |
Vector
|
normal vector |
Classes
Members
slope
Slope of the ray - angle in radians between ray and axe x from 0 to 2PI
- Source:
Methods
contains(pt) → {boolean}
Returns true if point belongs to ray
- Source:
Parameters:
Name | Type | Description |
---|---|---|
pt |
Point
|
Query point |
Returns:
- Type:
-
boolean
coord(pt) → {number}
Return coordinate of the point that lies on the ray in the transformed
coordinate system where center is the projection of the point(0,0) to
the line containing this ray and axe y is collinear to the normal vector.
This method assumes that point lies on the ray
This method assumes that point lies on the ray
- Source:
Parameters:
Name | Type | Description |
---|---|---|
pt |
Point
|
point on a ray |
Returns:
- Type:
-
number
intersect(shape) → {Array.<Point>}
Returns array of intersection points between ray and another shape
- Source:
Parameters:
Name | Type | Description |
---|---|---|
shape |
Shape
|
Shape to intersect with ray |
rotate(angle, center)
Return new line rotated by angle
- Source:
Parameters:
Name | Type | Description |
---|---|---|
angle |
number
|
angle in radians |
center |
Point
|
center of rotation |
split(pt)
Split ray with point and return array of segment and new ray
- Source:
Parameters:
Name | Type | Description |
---|---|---|
pt |
Point
|
Returns:
[Segment,Ray]
svg(box, attrs)
Return string to draw svg segment representing ray inside given box
- Source:
Parameters:
Name | Type | Description |
---|---|---|
box |
Box
|
Box representing drawing area |
attrs |
Object
|
an object with attributes of svg segment element |