Learn R Programming

pcds (version 0.1.4)

funsAB2CMTe: The lines joining two vertices to the center of mass in standard equilateral triangle

Description

Two functions, lA_CM.Te and lB_CM.Te of class "TriLines". Returns the equation, slope, intercept, and \(y\)-coordinates of the lines joining \(A\) and \(CM\) and also \(B\) and \(CM\).

lA_CM.Te is the line joining \(A\) to the center of mass, \(CM\), and

lB_CM.Te is the line joining \(B\) to the center of mass, \(CM\), 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_CM.Te(x)

lB_CM.Te(x)

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. It is "CM" for these two functions.

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.

Arguments

x

A single scalar or a vector of scalars which is the argument of the functions lA_CM.Te and lB_CM.Te.

Author

Elvan Ceyhan

See Also

lA_M.Te, lB_M.Te, and lC_M.Te

Examples

Run this code
#Examples for lA_CM.Te
A<-c(0,0); B<-c(1,0); C<-c(1/2,sqrt(3)/2);
Te<-rbind(A,B,C)
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

lnACM<-lA_CM.Te(x)
lnACM
summary(lnACM)
plot(lnACM)

CM<-(A+B+C)/3;
D1<-(B+C)/2; D2<-(A+C)/2; D3<-(A+B)/2;
Ds<-rbind(D1,D2,D3)

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<-Ds
segments(L[,1], L[,2], R[,1], R[,2], lty=2)

txt<-rbind(Te,CM,D1,D2,D3,c(.25,lA_CM.Te(.25)$y),c(.75,lB_CM.Te(.75)$y))
xc<-txt[,1]+c(-.02,.02,.02,.05,.05,-.03,.0,0,0)
yc<-txt[,2]+c(.02,.02,.02,.02,0,.02,-.04,0,0)
txt.str<-c("A","B","C","CM","D1","D2","D3","lA_CM.Te(x)","lB_CM.Te(x)")
text(xc,yc,txt.str)

lA_CM.Te(.25)$y

#Examples for lB_CM.Te
A<-c(0,0); B<-c(1,0); C<-c(1/2,sqrt(3)/2);
Te<-rbind(A,B,C)
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

lnBCM<-lB_CM.Te(x)
lnBCM
summary(lnBCM)
plot(lnBCM,xlab="x",ylab="y")

lB_CM.Te(.25)$y

Run the code above in your browser using DataLab