Line3D: The line crossing 3D point 'p' in the direction of 'vector'...

View source: R/AuxGeometry.R

Line3DR Documentation

The line crossing 3D point p in the direction of vector v (or if v is a point, in direction of v-r_0)

Description

An object of class "Lines3D". Returns the equation, x-, y-, and z-coordinates of the line crossing 3D point r_0 in the direction of vector v (of if v is a point, in the direction of v-r_0) with the parameter t being provided in vector t.

Usage

Line3D(p, v, t, dir.vec = TRUE)

Arguments

p

A 3D point through which the straight line passes.

v

A 3D vector which determines the direction of the straight line (i.e., the straight line would be parallel to this vector) if the dir.vec=TRUE, otherwise it is 3D point and v-r_0 determines the direction of the the straight line.

t

A scalar or a vector of scalars representing the parameter of the coordinates of the line (for the form: x=p_0 + a t, y=y_0 + b t, and z=z_0 + c t where r_0=(p_0,y_0,z_0) and v=(a,b,c) if dir.vec=TRUE, else v-r_0=(a,b,c)).

dir.vec

A logical argument about v, if TRUE v is treated as a vector, else v is treated as a point and so the direction vector is taken to be v-r_0.

Value

A list with the elements

desc

A description of the line

mtitle

The "main" title for the plot of the line

pts

The input points that determine a line and/or a plane, NULL for this function.

pnames

The names of the input points that determine a line and/or a plane, NULL for this function.

vecs

The point p and the vector v (if dir.vec=TRUE) or the point v (if dir.vec=FALSE). The first row is p and the second row is v.

vec.names

The names of the point p and the vector v (if dir.vec=TRUE) or the point v (if dir.vec=FALSE).

x,y,z

The x-, y-, and z-coordinates of the point(s) of interest on the line.

tsq

The scalar or the vector of the parameter in defining each coordinate of the line for the form: x=p_0 + a t, y=y_0 + b t, and z=z_0 + c t where r_0=(p_0,y_0,z_0) and v=(a,b,c) if dir.vec=TRUE, else v-r_0=(a,b,c).

equation

Equation of the line passing through point p in the direction of the vector v (if dir.vec=TRUE) else in the direction of v-r_0. The line equation is in the form: x=p_0 + a t, y=y_0 + b t, and z=z_0 + c t where r_0=(p_0,y_0,z_0) and v=(a,b,c) if dir.vec=TRUE, else v-r_0=(a,b,c).

Author(s)

Elvan Ceyhan

See Also

line, paraline3D, and Plane

Examples

## Not run: 
A<-c(1,10,3); B<-c(1,1,3);

vecs<-rbind(A,B)

Line3D(A,B,.1)
Line3D(A,B,.1,dir.vec=FALSE)

tr<-range(vecs);
tf<-(tr[2]-tr[1])*.1
#how far to go at the lower and upper ends in the x-coordinate
tsq<-seq(-tf*10-tf,tf*10+tf,l=5)  #try also l=10, 20, or 100

lnAB3D<-Line3D(A,B,tsq)
#try also lnAB3D<-Line3D(A,B,tsq,dir.vec=FALSE)
lnAB3D
summary(lnAB3D)
plot(lnAB3D)

x<-lnAB3D$x
y<-lnAB3D$y
z<-lnAB3D$z

zr<-range(z)
zf<-(zr[2]-zr[1])*.2
Bv<-B*tf*5

Xlim<-range(x)
Ylim<-range(y)
Zlim<-range(z)

xd<-Xlim[2]-Xlim[1]
yd<-Ylim[2]-Ylim[1]
zd<-Zlim[2]-Zlim[1]

Dr<-A+min(tsq)*B

plot3D::lines3D(x, y, z, phi = 0, bty = "g",
main="Line Crossing A \n in the Direction of OB",
xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05),
zlim=Zlim+zd*c(-.1,.1),
        pch = 20, cex = 2, ticktype = "detailed")
plot3D::arrows3D(Dr[1],Dr[2],Dr[3]+zf,Dr[1]+Bv[1],
Dr[2]+Bv[2],Dr[3]+zf+Bv[3], add=TRUE)
plot3D::points3D(A[1],A[2],A[3],add=TRUE)
plot3D::arrows3D(A[1],A[2],A[3]-2*zf,A[1],A[2],A[3],lty=2, add=TRUE)
plot3D::text3D(A[1],A[2],A[3]-2*zf,labels="initial point",add=TRUE)
plot3D::text3D(A[1],A[2],A[3]+zf/2,labels=expression(r[0]),add=TRUE)
plot3D::arrows3D(Dr[1]+Bv[1]/2,Dr[2]+Bv[2]/2,Dr[3]+3*zf+Bv[3]/2,
Dr[1]+Bv[1]/2,Dr[2]+Bv[2]/2,Dr[3]+zf+Bv[3]/2,lty=2, add=TRUE)
plot3D::text3D(Dr[1]+Bv[1]/2,Dr[2]+Bv[2]/2,Dr[3]+3*zf+Bv[3]/2,
labels="direction vector",add=TRUE)
plot3D::text3D(Dr[1]+Bv[1]/2,Dr[2]+Bv[2]/2,
Dr[3]+zf+Bv[3]/2,labels="v",add=TRUE)
plot3D::text3D(0,0,0,labels="O",add=TRUE)

## End(Not run)


elvanceyhan/pcds documentation built on June 29, 2023, 8:12 a.m.