| Line {PlaneGeometry} | R Documentation |
R6 class representing a line
Description
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.
Active bindings
Aget or set the point A
Bget or set the point B
extendAget or set
extendAextendBget or set
extendB
Methods
Public methods
Method new()
Create a new Line object.
Usage
Line$new(A, B, extendA = TRUE, extendB = TRUE)
Arguments
A, Bpoints
extendA, extendBlogical values
Returns
A new Line object.
Examples
l <- Line$new(c(1,1), c(1.5,1.5), FALSE, TRUE) l l$A l$A <- c(0,0) l
Method print()
Show instance of a line object.
Usage
Line$print(...)
Arguments
...ignored
Examples
Line$new(c(0,0), c(1,0), FALSE, TRUE)
Method length()
Segment length, returns the length of the segment joining the two points defining the line.
Usage
Line$length()
Method directionAndOffset()
Direction (angle between 0 and 2pi) and offset (positive number) of the reference line.
Usage
Line$directionAndOffset()
Details
The equation of the line is cos(θ)x+sin(θ)y=d where θ is the direction and d is the offset.
Method isEqual()
Check whether the reference line equals a given line,
without taking into account extendA and extendB.
Usage
Line$isEqual(line)
Arguments
linea
Lineobject
Returns
TRUE or FALSE.
Method isParallel()
Check whether the reference line is parallel to a given line.
Usage
Line$isParallel(line)
Arguments
linea
Lineobject
Returns
TRUE or FALSE.
Method isPerpendicular()
Check whether the reference line is perpendicular to a given line.
Usage
Line$isPerpendicular(line)
Arguments
linea
Lineobject
Returns
TRUE or FALSE.
Method includes()
Whether a point belongs to the reference line.
Usage
Line$includes(M, strict = FALSE, checkCollinear = TRUE)
Arguments
Mthe point for which we want to test whether it belongs to the line
strictlogical, whether to take into account
extendAandextendBcheckCollinearlogical, whether to check the collinearity of
A,B,M; set toFALSEonly if you are sure thatMis on the line(AB)in case if you usestrict=TRUE
Returns
TRUE or FALSE.
Examples
A <- c(0,0); B <- c(1,2); M <- c(3,6) l <- Line$new(A, B, FALSE, FALSE) l$includes(M, strict = TRUE)
Method perpendicular()
Perpendicular line passing through a given point.
Usage
Line$perpendicular(M, extendH = FALSE, extendM = TRUE)
Arguments
Mthe point through which the perpendicular passes.
extendHlogical, whether to extend the perpendicular line beyond the meeting point
extendMlogical, whether to extend the perpendicular line beyond the point
M
Returns
A Line object; its two points are the
meeting point and the point M.
Method parallel()
Parallel to the reference line passing through a given point.
Usage
Line$parallel(M)
Arguments
Ma point
Returns
A Line object.
Method projection()
Orthogonal projection of a point to the reference line.
Usage
Line$projection(M)
Arguments
Ma point
Returns
A point.
Method distance()
Distance from a point to the reference line.
Usage
Line$distance(M)
Arguments
Ma point
Returns
A positive number.
Method reflection()
Reflection of a point with respect to the reference line.
Usage
Line$reflection(M)
Arguments
Ma point
Returns
A point.
Method rotate()
Rotate the reference line.
Usage
Line$rotate(alpha, O, degrees = TRUE)
Arguments
alphaangle of rotation
Ocenter of rotation
degreeslogical, whether
alphais given in degrees
Returns
A Line object.
Method translate()
Translate the reference line.
Usage
Line$translate(v)
Arguments
vthe vector of translation
Returns
A Line object.
Method invert()
Invert the reference line.
Usage
Line$invert(inversion)
Arguments
inversionan
Inversionobject
Returns
A Circle object or a Line object.
Method clone()
The objects of this class are cloneable with this method.
Usage
Line$clone(deep = FALSE)
Arguments
deepWhether to make a deep clone.
Examples
## ------------------------------------------------
## 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)