Line | R Documentation |
A line is given by two distinct points,
named A
and B
, and two logical values extendA
and extendB
, indicating whether the line must be extended
beyond A
and B
respectively. Depending on extendA
and extendB
, the line is an infinite line, a half-line, or a segment.
A
get or set the point A
B
get or set the point B
extendA
get or set extendA
extendB
get or set extendB
new()
Create a new Line
object.
Line$new(A, B, extendA = TRUE, extendB = TRUE)
A, B
points
extendA, extendB
logical values
A new Line
object.
l <- Line$new(c(1,1), c(1.5,1.5), FALSE, TRUE) l l$A l$A <- c(0,0) l
print()
Show instance of a line object.
Line$print(...)
...
ignored
Line$new(c(0,0), c(1,0), FALSE, TRUE)
length()
Segment length, returns the length of the segment joining the two points defining the line.
Line$length()
directionAndOffset()
Direction (angle between 0 and 2pi) and offset (positive number) of the reference line.
Line$directionAndOffset()
The equation of the line is cos(θ)x+sin(θ)y=d where θ is the direction and d is the offset.
isEqual()
Check whether the reference line equals a given line,
without taking into account extendA
and extendB
.
Line$isEqual(line)
line
a Line
object
TRUE
or FALSE
.
isParallel()
Check whether the reference line is parallel to a given line.
Line$isParallel(line)
line
a Line
object
TRUE
or FALSE
.
isPerpendicular()
Check whether the reference line is perpendicular to a given line.
Line$isPerpendicular(line)
line
a Line
object
TRUE
or FALSE
.
includes()
Whether a point belongs to the reference line.
Line$includes(M, strict = FALSE, checkCollinear = TRUE)
M
the point for which we want to test whether it belongs to the line
strict
logical, whether to take into account extendA
and extendB
checkCollinear
logical, whether to check the collinearity of
A
, B
, M
; set to FALSE
only if you are sure
that M
is on the line (AB)
in case if you use
strict=TRUE
TRUE
or FALSE
.
A <- c(0,0); B <- c(1,2); M <- c(3,6) l <- Line$new(A, B, FALSE, FALSE) l$includes(M, strict = TRUE)
perpendicular()
Perpendicular line passing through a given point.
Line$perpendicular(M, extendH = FALSE, extendM = TRUE)
M
the point through which the perpendicular passes.
extendH
logical, whether to extend the perpendicular line beyond the meeting point
extendM
logical, whether to extend the perpendicular line
beyond the point M
A Line
object; its two points are the
meeting point and the point M
.
parallel()
Parallel to the reference line passing through a given point.
Line$parallel(M)
M
a point
A Line
object.
projection()
Orthogonal projection of a point to the reference line.
Line$projection(M)
M
a point
A point.
distance()
Distance from a point to the reference line.
Line$distance(M)
M
a point
A positive number.
reflection()
Reflection of a point with respect to the reference line.
Line$reflection(M)
M
a point
A point.
rotate()
Rotate the reference line.
Line$rotate(alpha, O, degrees = TRUE)
alpha
angle of rotation
O
center of rotation
degrees
logical, whether alpha
is given in degrees
A Line
object.
translate()
Translate the reference line.
Line$translate(v)
v
the vector of translation
A Line
object.
invert()
Invert the reference line.
Line$invert(inversion)
inversion
an Inversion
object
A Circle
object or a Line
object.
clone()
The objects of this class are cloneable with this method.
Line$clone(deep = FALSE)
deep
Whether to make a deep clone.
## ------------------------------------------------
## Method `Line$new`
## ------------------------------------------------
l <- Line$new(c(1,1), c(1.5,1.5), FALSE, TRUE)
l
l$A
l$A <- c(0,0)
l
## ------------------------------------------------
## Method `Line$print`
## ------------------------------------------------
Line$new(c(0,0), c(1,0), FALSE, TRUE)
## ------------------------------------------------
## Method `Line$includes`
## ------------------------------------------------
A <- c(0,0); B <- c(1,2); M <- c(3,6)
l <- Line$new(A, B, FALSE, FALSE)
l$includes(M, strict = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.