paraline {pcds} | R Documentation |
The line at a point p
parallel to the line segment
joining two distinct 2D points a
and b
Description
An object of class "Lines"
.
Returns the equation, slope, intercept
,
and y
-coordinates of the line crossing the
point p
and parallel to the line
passing through the points a
and b
with
x
-coordinates are provided in vector
x
.
Usage
paraline(p, a, b, x)
Arguments
p |
A 2D point at which the parallel line to line segment
joining |
a , b |
2D points that determine the line segment (the line will be parallel to this line segment). |
x |
A scalar or a |
Value
A list
with the elements
desc |
Description of the line
passing through point |
mtitle |
The |
points |
The input points |
x |
The input vector.
It can be a scalar or a |
y |
The output scalar or |
slope |
Slope of the line, |
intercept |
Intercept of the line
passing through point |
equation |
Equation of the line
passing through point |
Author(s)
Elvan Ceyhan
See Also
slope
, Line
, and perpline
,
line
in the generic stats
package,
and paraline3D
Examples
A<-c(1.1,1.2); B<-c(2.3,3.4); p<-c(.51,2.5)
paraline(p,A,B,.45)
pts<-rbind(A,B,p)
xr<-range(pts[,1])
xf<-(xr[2]-xr[1])*.25
#how far to go at the lower and upper ends in the x-coordinate
x<-seq(xr[1]-xf,xr[2]+xf,l=5) #try also l=10, 20, or 100
plnAB<-paraline(p,A,B,x)
plnAB
summary(plnAB)
plot(plnAB)
y<-plnAB$y
Xlim<-range(x,pts[,1])
if (!is.na(y[1])) {Ylim<-range(y,pts[,2])} else {Ylim<-range(pts[,2])}
xd<-Xlim[2]-Xlim[1]
yd<-Ylim[2]-Ylim[1]
pf<-c(xd,-yd)*.025
plot(A,pch=".",xlab="",ylab="",main="Line Crossing P and Parallel to AB",
xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05))
points(pts)
txt.str<-c("A","B","p")
text(pts+rbind(pf,pf,pf),txt.str)
segments(A[1],A[2],B[1],B[2],lty=2)
if (!is.na(y[1])) {lines(x,y,type="l",lty=1,xlim=Xlim,ylim=Ylim)} else {abline(v=p[1])}
tx<-(A[1]+B[1])/2;
if (!is.na(y[1])) {ty<-paraline(p,A,B,tx)$y} else {ty=p[2]}
text(tx,ty,"line parallel to AB\n and crossing p")