Members
rac :Rac
Instance of Rac used for drawing and passed along to any created
object.
Methods
angleToPoint(point) → {Rac.Angle}
Returns the angle from this.start to point.
When this.start and point are considered
equal, returns this.angle.
- See:
Parameters:
| Name | Type | Description |
|---|---|---|
point |
Rac.Point
|
A |
arc(radius, endAngleopt, clockwiseopt) → {Rac.Arc}
Returns a new Arc with center at this.start, start at this.angle
and the given arc properties.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
radius |
number
|
The radius of the new |
||
endAngle |
Rac.Angle
|
number
|
<optional> |
null |
The end |
clockwise |
boolean
|
<optional> |
true |
The orientation of the new |
arcToAngleDistance(radius, angleDistance, clockwiseopt) → {Rac.Arc}
Returns a new Arc with center at this.start, start at this.angle,
and end at the given angleDistance from this.start in the
clockwise orientation.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
radius |
number
|
The radius of the new |
||
angleDistance |
Rac.Angle
|
number
|
The angle distance from
|
||
clockwise |
boolean
|
<optional> |
true |
The orientation of the new |
distanceToProjectedPoint(point) → {number}
Returns the distance from this.start to the projection of point
onto the ray.
The returned distance is positive when the projected point is towards the direction of the ray, and negative when it is behind.
Parameters:
| Name | Type | Description |
|---|---|---|
point |
Rac.Point
|
A |
equals(otherRay) → {boolean}
Returns true when start and angle in both rays are equal.
When otherRay is any class other that Rac.Ray, returns false.
Parameters:
| Name | Type | Description |
|---|---|---|
otherRay |
Rac.Ray
|
A |
inverse() → {Rac.Ray}
Returns a new Ray pointing towards
angle.inverse().
perpendicular(clockwiseopt) → {Rac.Ray}
Returns a new Ray pointing towards the
perpendicular angle of
angle in the clockwise orientation.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
clockwise |
boolean
|
<optional> |
true |
The orientation of the perpendicular |
pointAtCanvasEdge() → (nullable) {Rac.Point}
Returns a new Point located where the ray touches the canvas edge.
When the ray is outside the canvas and pointing away, null is
returned.
Added to Rac.Ray.prototype when Rac.P5Drawer is setup as
rac.drawer.
pointAtDistance(distance) → {Rac.Point}
Returns a new Point in the ray at the given distance from
this.start. When distance is negative, the new Point is calculated
in the inverse direction of angle.
Parameters:
| Name | Type | Description |
|---|---|---|
distance |
number
|
The distance from |
pointAtIntersection(otherRay) → {Rac.Point}
Returns a new Point at the intersection of this and otherRay.
When the rays are parallel, returns null since no intersection is
possible.
Both rays are considered unbounded lines.
Parameters:
| Name | Type | Description |
|---|---|---|
otherRay |
Rac.Ray
|
A |
pointAtX(x) → {Rac.Point}
Returns a new Point located in the ray where the x coordinate is x.
When the ray is vertical, returns null since no single point with x
coordinate at x is possible.
The ray is considered a unbounded line.
Parameters:
| Name | Type | Description |
|---|---|---|
x |
number
|
The x coordinate to calculate a point in the ray |
pointAtY(y)
Returns a new Point located in the ray where the y coordinate is y.
When the ray is horizontal, returns null since no single point with y
coordinate at y is possible.
The ray is considered an unbounded line.
Parameters:
| Name | Type | Description |
|---|---|---|
y |
number
|
The y coordinate to calculate a point in the ray |
pointOrientation(point) → {boolean}
Returns true when the angle to the given point is located clockwise
of the ray or false when located counter-clockwise.
Parameters:
| Name | Type | Description |
|---|---|---|
point |
Rac.Point
|
A |
pointProjection(point) → {Rac.Point}
Returns a new Point at the projection of point onto the ray. The
projected point is the closest possible point to point.
The ray is considered an unbounded line.
Parameters:
| Name | Type | Description |
|---|---|---|
point |
Rac.Point
|
A |
rayAtCanvasEdge() → (nullable) {Rac.Ray}
Returns a new Ray that starts at the point where the this touches
the canvas edge and pointed towards the inside of the canvas.
When the ray is outside the canvas and pointing away, null is
returned.
Added to Rac.Ray.prototype when Rac.P5Drawer is setup as
rac.drawer.
rayToPoint(point) → {Rac.Ray}
Returns a new Ray from this.start to point.
When this.start and point are considered
equal, the new Ray will use this.angle.
- See:
Parameters:
| Name | Type | Description |
|---|---|---|
point |
Rac.Point
|
A |
segment(length) → {Rac.Segment}
Returns a new Segment using this and the given length.
Parameters:
| Name | Type | Description |
|---|---|---|
length |
number
|
The length of the new |
segmentToIntersection(otherRay) → {Rac.Segment}
Returns a new Segment starting at this.start and ending at the
intersection of this and otherRay.
When the rays are parallel, returns null since no intersection is
possible.
When this.start and the intersection point are considered
equal, the new Segment will use
this.angle.
Both rays are considered unbounded lines.
Parameters:
| Name | Type | Description |
|---|---|---|
otherRay |
Rac.Ray
|
A |
segmentToPoint(point) → {Rac.Segment}
Returns a new Segment from this.start to point.
When this.start and point are considered
equal, the new Segment will use
this.angle.
- See:
Parameters:
| Name | Type | Description |
|---|---|---|
point |
Rac.Point
|
A |
slope() → (nullable) {number}
Returns the slope of the ray, or null if the ray is vertical.
In the line formula y = mx + b the slope is m.
toString(digitsopt) → {string}
Returns a string representation intended for human consumption.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
digits |
number
|
<optional> |
null |
The number of digits to print after the decimal point, when ommited all digits are printed |
translatePerpendicular(distance, clockwiseopt) → {Rac.Ray}
Returns a new Ray with start moved by the given distance toward the
angle.perpendicular(). All other properties are copied from this.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
distance |
number
|
The distance to move |
||
clockwise |
boolean
|
<optional> |
true |
The orientation of the perpendicular |
translateToAngle(angle, distance) → {Rac.Ray}
Returns a new Ray with start moved towards angle by the given
distance. All other properties are copied from this.
Parameters:
| Name | Type | Description |
|---|---|---|
angle |
Rac.Angle
|
number
|
An |
distance |
number
|
The distance to move |
translateToDistance(distance) → {Rac.Ray}
Returns a new Ray with start moved along the ray by the given
distance. All other properties are copied from this.
When distance is negative, start is moved in
the inverse direction of angle.
Parameters:
| Name | Type | Description |
|---|---|---|
distance |
number
|
The distance to move |
withAngle(newAngle) → {Rac.Ray}
Returns a new Ray with angle set to newAngle.
All other properties are copied from this.
Parameters:
| Name | Type | Description |
|---|---|---|
newAngle |
Rac.Angle
|
number
|
The angle for the new |
withAngleAdd(angle) → {Rac.Ray}
Returns a new Ray with angle added to this.angle.
All other properties are copied from this.
Parameters:
| Name | Type | Description |
|---|---|---|
angle |
Rac.Angle
|
number
|
The angle to add |
withAngleShift(angle, clockwiseopt) → {Rac.Ray}
Returns a new Ray with angle set to
this.angle.shift(angle, clockwise).
All other properties are copied from this.
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
angle |
Rac.Angle
|
number
|
The angle to be shifted by |
||
clockwise |
boolean
|
<optional> |
true |
The orientation of the shift |
withStart(newStart) → {Rac.Ray}
Returns a new Ray with start set to newStart.
All other properties are copied from this.
Parameters:
| Name | Type | Description |
|---|---|---|
newStart |
Rac.Point
|
The start for the new |
withX(newX) → {Rac.Ray}
Returns a new Ray with start.x set to newX.
All other properties are copied from this.
Parameters:
| Name | Type | Description |
|---|---|---|
newX |
number
|
The x coordinate for the new |
withY(newY) → {Rac.Ray}
Returns a new Ray with start.y set to newY.
All other properties are copied from this.
Parameters:
| Name | Type | Description |
|---|---|---|
newY |
number
|
The y coordinate for the new |
yIntercept() → (nullable) {number}
Returns the y-intercept: the point at which the ray, extended in both
directions, intercepts with the y-axis; or null if the ray is
vertical.
In the line formula y = mx + b the y-intercept is b.