| in.triangle | R Documentation | 
Checks if the point p lies in the triangle,
tri, using the barycentric
coordinates, generally denoted as (\alpha,\beta,\gamma).
If all (normalized or non-normalized)
barycentric coordinates are positive then the point p is
inside the triangle,
if all are nonnegative with one or more are zero,
then p falls in the boundary. If some of the
barycentric coordinates are negative,
then p falls outside the triangle.
boundary is a logical argument (default=TRUE)
to include boundary or not, so if it is TRUE,
the function checks if the point, p,
lies in the closure of the triangle (i.e., interior and boundary
combined); else, it checks if p lies
in the interior of the triangle.
in.triangle(p, tri, boundary = TRUE)
p | 
 A 2D point to be checked whether it is inside the triangle or not.  | 
tri | 
 A   | 
boundary | 
 A logical parameter (default=  | 
A list with two elements
in.tri | 
 A logical output, it is   | 
barycentric | 
 The barycentric coordinates   | 
Elvan Ceyhan
in.tri.all and on.convex.hull
from the interp package for documentation for in.convex.hull
## Not run: 
A<-c(1,1); B<-c(2,0); C<-c(1.5,2); p<-c(1.4,1.2)
Tr<-rbind(A,B,C)
in.triangle(p,Tr)
p<-c(.4,-.2)
in.triangle(p,Tr)
#for the vertex A
in.triangle(A,Tr)
in.triangle(A,Tr,boundary = FALSE)
#for a point on the edge AB
D3<-(A+B)/2
in.triangle(D3,Tr)
in.triangle(D3,Tr,boundary = FALSE)
#for a NA entry point
p<-c(NA,.2)
in.triangle(p,Tr)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.