Constructor
new Point(rac, x, y)
Creates a new Point
instance.
Parameters:
Name | Type | Description |
---|---|---|
rac |
Rac
|
Instance to use for drawing and creating other objects |
x |
number
|
The x coordinate |
y |
number
|
The y coordinate |
Members
rac :Rac
Intance of Rac
used for drawing and passed along to any created
object.
Methods
add(x, y) → {Rac.Point}
Returns a new Point
by adding the x
and y
components to this
.
Parameters:
Name | Type | Description |
---|---|---|
x |
number
|
The x coodinate to add |
y |
number
|
The y coodinate to add |
addPoint(point) → {Rac.Point}
Returns a new Point
by adding the components of point
to this
.
Parameters:
Name | Type | Description |
---|---|---|
point |
Rac.Point
|
A |
addX(x) → {Rac.Point}
Returns a new Point
with x
added to this.x
.
Parameters:
Name | Type | Description |
---|---|---|
x |
number
|
The x coordinate to add |
addY(y) → {Rac.Point}
Returns a new Point
with y
added to this.y
.
Parameters:
Name | Type | Description |
---|---|---|
y |
number
|
The y coordinate to add |
angleToPoint(point, defaultAngleopt) → {Rac.Angle}
Returns the angle from this
to point
.
When this
and point
are considered
equal, returns the angle produced with
defaultAngle
.
- See:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
point |
Rac.Point
|
A |
||
defaultAngle |
Rac.Angle
|
number
|
<optional> |
instance.Angle.Zero |
An |
arc(radius, someStartopt, someEndopt, clockwiseopt) → {Rac.Arc}
Returns a new Arc
with center at this
and the given arc properties.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
radius |
number
|
The radius of the new |
||
someStart |
Rac.Angle
|
number
|
<optional> |
rac.Angle.zero |
The start
|
someEnd |
Rac.Angle
|
number
|
<optional> |
null |
The end |
clockwise |
boolean
|
<optional> |
true |
The orientation of the new |
distanceToPoint(point) → {number}
Returns the distance from this
to point
, or returns 0
when
this
and point
are considered equal.
- See:
Parameters:
Name | Type | Description |
---|---|---|
point |
Rac.Point
|
A |
equals(otherPoint) → {boolean}
Returns true
when the difference with otherPoint
for each coordinate is
under Rac#equalityThreshold
, otherwise returns false
.
When otherPoint
is any class other that Rac.Point
, returns false
.
Values are compared using Rac#equals
.
- See:
Parameters:
Name | Type | Description |
---|---|---|
otherPoint |
Rac.Point
|
A |
negative() → {Rac.Point}
Returns a new Point
with the negative coordinate values of this
.
pointToAngle(angle, distance) → {Rac.Point}
Returns a new Point
at a distance
from this
in the direction of
angle
.
Parameters:
Name | Type | Description |
---|---|---|
angle |
Rac.Angle
|
number
|
An |
distance |
number
|
The distance to the new |
ray(angle) → {Rac.Ray}
Returns a new Ray
from this
towards angle
.
Parameters:
Name | Type | Description |
---|---|---|
angle |
Rac.Angle
|
number
|
The |
rayTangentToArc(arc, clockwiseopt) → (nullable) {Rac.Ray}
Returns a new Ray
that starts at this
and is tangent to arc
, when
no tangent is possible returns null
.
The new Ray
will be in the clockwise
side of the ray formed
from this
towards arc.center
. arc
is considered a complete
circle.
When this
is inside arc
no tangent segment is possible and null
is returned.
A special case is considered when arc.radius
is considered to be 0
and this
is equal to arc.center
. In this case the angle between
this
and arc.center
is assumed to be the inverse of arc.start
,
thus the new Ray
will have an angle perpendicular to
arc.start.inverse()
, in the clockwise
orientation.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
arc |
Rac.Arc
|
An |
||
clockwise |
boolean
|
<optional> |
true |
the orientation of the new |
rayToPoint(point, defaultAngleopt) → {Rac.Ray}
Returns a new Ray
from this
towards point
.
When this
and point
are considered equal, the new Ray
will use
the angle produced with defaultAngle
.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
point |
Rac.Point
|
A |
||
defaultAngle |
Rac.Angle
|
number
|
<optional> |
instance.Angle.Zero |
An |
rayToProjectionInRay(ray) → {Rac.Ray}
Returns a new Ray
from this
to the projection of this
in ray
.
When the projected point is equal to this
the produced ray will have
an angle perpendicular to ray
in the clockwise direction.
Parameters:
Name | Type | Description |
---|---|---|
ray |
Rac.Ray
|
A |
segmentTangentToArc(arc, clockwiseopt) → (nullable) {Rac.Segment}
Returns a new Segment
that starts at this
and is tangent to arc
,
when no tangent is possible returns null
.
The new Segment
will be in the clockwise
side of the ray formed
from this
towards arc.center
, and its end point will be at the
contact point with arc
which is considered as a complete circle.
When this
is inside arc
no tangent segment is possible and null
is returned.
A special case is considered when arc.radius
is considered to be 0
and this
is equal to arc.center
. In this case the angle between
this
and arc.center
is assumed to be the inverse of arc.start
,
thus the new Segment
will have an angle perpendicular to
arc.start.inverse()
, in the clockwise
orientation.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
arc |
Rac.Arc
|
An |
||
clockwise |
boolean
|
<optional> |
true |
the orientation of the new |
segmentToAngle(angle, length) → {Rac.Segment}
Returns a new Segment
from this
towards angle
with the given
length
.
Parameters:
Name | Type | Description |
---|---|---|
angle |
Rac.Angle
|
number
|
An |
length |
number
|
The length of the new |
segmentToPoint(point, defaultAngleopt) → {Rac.Segment}
Returns a new Segment
from this
to point
.
When this
and point
are considered equal,
the new Segment
will use the angle produced with defaultAngle
.
- See:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
point |
Rac.Point
|
A |
||
defaultAngle |
Rac.Angle
|
number
|
<optional> |
instance.Angle.Zero |
An |
segmentToProjectionInRay(ray) → {Rac.Segment}
Returns a new Segment
from this
to the projection of this
in
ray
.
When the projected point is equal to this
, the new Segment
will
have an angle perpendicular to ray
in the clockwise direction.
Parameters:
Name | Type | Description |
---|---|---|
ray |
Rac.Ray
|
A |
subtract(x, y) → {Rac.Point}
Returns a new Point
by subtracting the x
and y
components.
Parameters:
Name | Type | Description |
---|---|---|
x |
number
|
The x coodinate to subtract |
y |
number
|
The y coodinate to subtract |
subtractPoint(point) → {Rac.Point}
Returns a new Point
by subtracting the components of point
.
Parameters:
Name | Type | Description |
---|---|---|
point |
Rac.Point
|
A |
text(string, format) → {Rac.Text}
Returns a new Text
with the given string
and format
.
Parameters:
Name | Type | Description |
---|---|---|
string |
string
|
The string of the new |
format |
Rac.Text.Format
|
The format of the new |
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 |
vertex()
Calls p5.vertex
as to represent this Point
.
Added when Rac.P5Drawer
is setup as rac.drawer
.
withX(newX) → {Rac.Point}
Returns a new Point
with x
set to newX
.
Parameters:
Name | Type | Description |
---|---|---|
newX |
number
|
The x coordinate for the new |
withY(newY) → {Rac.Point}
Returns a new Point
with x
set to newX
.
Parameters:
Name | Type | Description |
---|---|---|
newY |
number
|
The y coordinate for the new |