rel.vert.std.tri: The index of the vertex region in the standard equilateral...

View source: R/AuxDelaunay.R

rel.vert.std.triR Documentation

The index of the vertex region in the standard equilateral triangle that contains a given point

Description

Returns the index of the vertex whose region contains point p in standard equilateral triangle T_e=T((0,0),(1,0),(1/2,\sqrt{3}/2)) with vertex regions are constructed with center M=(m_1,m_2) in Cartesian coordinates or M=(\alpha,\beta,\gamma) in barycentric coordinates in the interior of T_e. (see the plots in the example for illustrations).

The vertices of triangle, T_e, are labeled as 1,2,3 according to the row number the vertex is recorded in T_e. If the point, p, is not inside T_e, then the function yields NA as output. The corresponding vertex region is the polygon with the vertex, M, and projections from M to the edges on the lines joining vertices and M.

See also (\insertCiteceyhan:Phd-thesis,ceyhan:comp-geo-2010,ceyhan:mcap2012;textualpcds).

Usage

rel.vert.std.tri(p, M)

Arguments

p

A 2D point for which M-vertex region it resides in is to be determined in the standard equilateral triangle T_e.

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 T_e.

Value

A list with two elements

rv

Index of the vertex whose region contains point, p.

tri

The vertices of the triangle, T_e, where row number corresponds to the vertex index in rv with row 1=(0,0), row 2=(1,0), and row 3=(1/2,\sqrt{3}/2).

Author(s)

Elvan Ceyhan

References

\insertAllCited

See Also

rel.vert.std.triCM, rel.vert.tri, rel.vert.triCC, rel.vert.basic.triCC, rel.vert.triCM, and rel.vert.basic.tri

Examples

## Not run: 
A<-c(0,0); B<-c(1,0); C<-c(1/2,sqrt(3)/2);
Te<-rbind(A,B,C)
n<-20  #try also n<-40

set.seed(1)
Xp<-runif.std.tri(n)$gen.points

M<-as.numeric(runif.std.tri(1)$g)  #try also M<-c(.6,.2)

rel.vert.std.tri(Xp[1,],M)

Rv<-vector()
for (i in 1:n)
  Rv<-c(Rv,rel.vert.std.tri(Xp[i,],M)$rv)
Rv

Ds<-prj.cent2edges(Te,M)

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

if (dimension(M)==3) {M<-bary2cart(M,Te)}
#need to run this when M is given in barycentric coordinates

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

txt<-rbind(Te,M)
xc<-txt[,1]+c(-.02,.03,.02,0)
yc<-txt[,2]+c(.02,.02,.03,.05)
txt.str<-c("A","B","C","M")
text(xc,yc,txt.str)
text(Xp,labels=factor(Rv))

## End(Not run)


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