tri.find: Locate a point in a triangulation

View source: R/tri.find.R

tri.findR Documentation

Locate a point in a triangulation

Description

This subroutine locates a point P=(x,y) relative to a triangulation created by tri.mesh. If P is contained in a triangle, the three vertex indexes are returned. Otherwise, the indexes of the rightmost and leftmost visible boundary nodes are returned.

Usage

tri.find(tri.obj,x,y)

Arguments

tri.obj

an triangulation object

x

x-coordinate of the point

y

y-coordinate of the point

Value

A list with elements i1,i2,i3 containing nodal indexes, in counterclockwise order, of the vertices of a triangle containing P=(x,y), or, if P is not contained in the convex hull of the nodes, i1 indexes the rightmost visible boundary node, i2 indexes the leftmost visible boundary node, and i3 = 0. Rightmost and leftmost are defined from the perspective of P, and a pair of points are visible from each other if and only if the line segment joining them intersects no triangulation arc. If P and all of the nodes lie on a common line, then i1=i2=i3 = 0 on output.

Author(s)

A. Gebhardt

References

R. J. Renka (1996). Algorithm 751: TRIPACK: a constrained two-dimensional Delaunay triangulation package. ACM Transactions on Mathematical Software. 22, 1-8.

See Also

tri, print.tri, plot.tri, summary.tri, triangles, convex.hull

Examples

data(tritest)
tritest.tr<-tri.mesh(tritest$x,tritest$y)
plot(tritest.tr)
pnt<-list(x=0.3,y=0.4)
triangle.with.pnt<-tri.find(tritest.tr,pnt$x,pnt$y)
attach(triangle.with.pnt)
lines(tritest$x[c(i1,i2,i3,i1)],tritest$y[c(i1,i2,i3,i1)],col="red")
points(pnt$x,pnt$y)

tripack documentation built on Oct. 21, 2024, 5:07 p.m.

Related to tri.find in tripack...