area.polygon | R Documentation |
R^2
Returns the area of the polygon, h
,
in the real plane R^{2}
; the vertices of the polygon h
must be provided in clockwise or counter-clockwise order,
otherwise the function does not yield
the area of the polygon. Also, the polygon could be convex or non-convex.
See (\insertCiteweisstein-area-poly;textualpcds).
area.polygon(h)
h |
A |
area of the polygon h
Elvan Ceyhan
A<-c(0,0); B<-c(1,0); C<-c(0.5,.8);
Tr<-rbind(A,B,C);
area.polygon(Tr)
A<-c(0,0); B<-c(1,0); C<-c(.7,.6); D<-c(0.3,.8);
h1<-rbind(A,B,C,D);
#try also h1<-rbind(A,B,D,C) or h1<-rbind(A,C,B,D) or h1<-rbind(A,D,C,B);
area.polygon(h1)
Xlim<-range(h1[,1])
Ylim<-range(h1[,2])
xd<-Xlim[2]-Xlim[1]
yd<-Ylim[2]-Ylim[1]
plot(h1,xlab="",ylab="",main="A Convex Polygon with Four Vertices",
xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05))
polygon(h1)
xc<-rbind(A,B,C,D)[,1]+c(-.03,.03,.02,-.01)
yc<-rbind(A,B,C,D)[,2]+c(.02,.02,.02,.03)
txt.str<-c("A","B","C","D")
text(xc,yc,txt.str)
#when the triangle is degenerate, it gives zero area
B<-A+2*(C-A);
T2<-rbind(A,B,C)
area.polygon(T2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.