Learn R Programming

pcds (version 0.1.2)

funsAB2MTe: The lines joining the three vertices of the standard equilateral triangle to a center, M, of it

Description

Three functions, lA_M.Te, lB_M.Te and lC_M.Te of class "TriLines". Returns the equation, slope, intercept, and \(y\)-coordinates of the lines joining \(A\) and M, \(B\) and M, and also \(C\) and M.

lA_M.Te is the line joining \(A\) to the center, M, lB_M.Te is the line joining \(B\) to M, and lC_M.Te is the line joining C to M, in the standard equilateral triangle \(T_e=(A,B,C)\) with \(A=(0,0)\), \(B=(1,0)\), \(C=(1/2,\sqrt{3}/2)\); \(x\)-coordinates are provided in vector x

Usage

lA_M.Te(x, M)

lB_M.Te(x, M)

lC_M.Te(x, M)

Arguments

x

A single scalar or a vector of scalars.

M

A 2D point in Cartesian coordinates or a 3D point in barycentric coordinates which serves as a center in the interior of the standard equilateral triangle.

Value

A list with the elements

txt1

Longer description of the line.

txt2

Shorter description of the line (to be inserted over the line in the plot).

mtitle

The "main" title for the plot of the line.

cent

The center chosen inside the standard equilateral triangle.

cent.name

The name of the center inside the standard equilateral triangle.

tri

The triangle (it is the standard equilateral triangle for this function).

x

The input vector, can be a scalar or a vector of scalars, which constitute the \(x\)-coordinates of the point(s) of interest on the line.

y

The output vector, will be a scalar if x is a scalar or a vector of scalars if x is a vector of scalar, constitutes the \(y\)-coordinates of the point(s) of interest on the line.

slope

Slope of the line.

intercept

Intercept of the line.

equation

Equation of the line.

See Also

lA_CM.Te and lB_CM.Te

Examples

Run this code
# NOT RUN {
#Examples for lA_M.Te
A<-c(0,0); B<-c(1,0); C<-c(1/2,sqrt(3)/2);
Te<-rbind(A,B,C)

M<-c(.65,.2)  #try also M<-c(1,1,1)

xfence<-abs(A[1]-B[1])*.25 #how far to go at the lower and upper ends in the x-coordinate
x<-seq(min(A[1],B[1])-xfence,max(A[1],B[1])+xfence,by=.1)  #try also by=.01

lnAM<-lA_M.Te(x,M)
lnAM
summary(lnAM)
plot(lnAM)

Ds<-cp2e.tri(Te,M)
#finds the projections from a point M=(m1,m2) to the edges on the
#extension of the lines joining M to the vertices in the triangle Te

Xlim<-range(Te[,1])
Ylim<-range(Te[,2])
xd<-Xlim[2]-Xlim[1]
yd<-Ylim[2]-Ylim[1]

plot(Te,pch=".",xlab="",ylab="",
xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05))
polygon(Te)
L<-Te; R<-rbind(M,M,M)
segments(L[,1], L[,2], R[,1], R[,2], lty=2)
L<-Ds; R<-rbind(M,M,M)
segments(L[,1], L[,2], R[,1], R[,2], lty=3,col=2)

txt<-rbind(Te,M,Ds,c(.25,lA_M.Te(.25,M)$y),c(.4,lB_M.Te(.4,M)$y),
c(.60,lC_M.Te(.60,M)$y))
xc<-txt[,1]+c(-.02,.02,.02,.02,.04,-.03,.0,0,0,0)
yc<-txt[,2]+c(.02,.02,.02,.05,.02,.03,-.03,0,0,0)
txt.str<-c("A","B","C","M","D1","D2","D3","lA_M.Te(x)","lB_M.Te(x)","lC_M.Te(x)")
text(xc,yc,txt.str)

lA_M.Te(.25,M)

#Examples for lB_M.Te
A<-c(0,0); B<-c(1,0); C<-c(1/2,sqrt(3)/2);
Te<-rbind(A,B,C)

M<-c(.65,.2)  #try also M<-c(1,1,1)

xfence<-abs(A[1]-B[1])*.25 #how far to go at the lower and upper ends in the x-coordinate
x<-seq(min(A[1],B[1])-xfence,max(A[1],B[1])+xfence,by=.1)  #try also by=.01

lnBM<-lB_M.Te(x,M)
lnBM
summary(lnBM)
plot(lnBM)

lB_M.Te(.25,M)

#Examples for lC_M.Te
A<-c(0,0); B<-c(1,0); C<-c(1/2,sqrt(3)/2);
Te<-rbind(A,B,C)

M<-c(.65,.2)  #try also M<-c(1,1,1)

xfence<-abs(A[1]-B[1])*.25 #how far to go at the lower and upper ends in the x-coordinate
x<-seq(min(A[1],B[1])-xfence,max(A[1],B[1])+xfence,by=.1)  #try also by=.01

lnCM<-lC_M.Te(x,M)
lnCM
summary(lnCM)
plot(lnCM)

lC_M.Te(.25,M)

# }

Run the code above in your browser using DataLab