Learn R Programming

pcds (version 0.1.8)

paraline: 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)

Value

A list with the elements

desc

Description of the line passing through point p and parallel to line segment joining a and b

mtitle

The "main" title for the plot of the line passing through point p and parallel to line segment joining a and b

points

The input points p, a, and b (stacked row-wise, i.e., point p is in row 1, point a is in row 2 and point b is in row 3). Line parallel to ab crosses p.

x

The input vector. It can be a scalar or a vector of scalars, which constitute the \(x\)-coordinates of the point(s) of interest on the line passing through point p and parallel to line segment joining a and b.

y

The output scalar or vector which constitutes the \(y\)-coordinates of the point(s) of interest on the line passing through point p and parallel to line segment joining a and b. If x is a scalar, then y will be a scalar and if x is a vector of scalars, then y will be a vector of scalars.

slope

Slope of the line, Inf is allowed, passing through point p and parallel to line segment joining a and b

intercept

Intercept of the line passing through point p and parallel to line segment joining a and b

equation

Equation of the line passing through point p and parallel to line segment joining a and b

Arguments

p

A 2D point at which the parallel line to line segment joining a and b crosses.

a, b

2D points that determine the line segment (the line will be parallel to this line segment).

x

A scalar or a vector of scalars representing the \(x\)-coordinates of the line parallel to ab and crossing p.

Author

Elvan Ceyhan

See Also

slope, Line, and perpline, line in the generic stats package, and paraline3D

Examples

Run this code
# \donttest{
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")
# }

Run the code above in your browser using DataLab