Learn R Programming

pcds (version 0.1.4)

seg.tri.supp: The auxiliary triangle to define the support of type I segregation

Description

Returns the triangle whose intersection with a general triangle gives the support for type I segregation given the delta (i.e., \(\delta 100\) % area of a triangle around the vertices is chopped off). See the plot in the examples.

Caveat: the vertices of this triangle may be outside the triangle, tri, depending on the value of delta (i.e., for small values of delta).

Usage

seg.tri.supp(delta, tri)

Value

the vertices of the triangle (stacked row-wise) whose intersection with a general triangle gives the support for type I segregation for the given delta

Arguments

delta

A positive real number between 0 and 1 that determines the percentage of area of the triangle around the vertices forbidden for point generation.

tri

Three 2D points, stacked row-wise, each row representing a vertex of the triangle.

Author

Elvan Ceyhan

See Also

rsegTe and rsegMT

Examples

Run this code
#the standard equilateral triangle
A<-c(0,0); B<-c(1,0); C<-c(1/2,sqrt(3)/2);
Te<-rbind(A,B,C);
delta<-.3  #try also .5,.75,.85
seg.tri.supp(delta,Te)

Tseg<-seg.tri.supp(delta,Te)

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

oldpar <- par(no.readonly = TRUE)
par(pty="s")
plot(Te,pch=".",xlab="",ylab="",
main="segregation support is the intersection\n of these two triangles"
     ,axes=TRUE,xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05))
polygon(Te)
polygon(Tseg,lty=2)

txt<-rbind(Te,Tseg)
xc<-txt[,1]+c(-.03,.03,.03,.05,.04,-.04)
yc<-txt[,2]+c(.02,.02,.04,-.03,0,0)
txt.str<-c("A","B","C","T1","T2","T3")
text(xc,yc,txt.str)
par(oldpar)

#for a general triangle
A<-c(1,1); B<-c(2,0); C<-c(1.5,2);
Tr<-rbind(A,B,C);
delta<-.3  #try also .5,.75,.85
Tseg<-seg.tri.supp(delta,Tr)

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

oldpar <- par(no.readonly = TRUE)
par(pty="s")
plot(Tr,pch=".",xlab="",ylab="",
main="segregation support is the intersection\n of these two triangles"
     ,axes=TRUE,xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05))
polygon(Tr)
polygon(Tseg,lty=2)

txt<-rbind(Tr,Tseg)
xc<-txt[,1]+c(-.03,.03,.03,.06,.04,-.04)
yc<-txt[,2]+c(.02,.02,.04,-.03,0,0)
txt.str<-c("A","B","C","T1","T2","T3")
text(xc,yc,txt.str)
par(oldpar)

dat.fr<-data.frame(a=Tr)
seg.tri.supp(delta,dat.fr)

Run the code above in your browser using DataLab