circumcenter.tri | R Documentation |
Returns the circumcenter a given triangle, tri
,
with vertices stacked row-wise.
See (\insertCiteweisstein-tri-centers,ceyhan:comp-geo-2010;textualpcds)
for triangle centers.
circumcenter.tri(tri)
tri |
A |
circumcenter of the triangle tri
Elvan Ceyhan
circumcenter.basic.tri
A<-c(1,1); B<-c(2,0); C<-c(1.5,2);
Tr<-rbind(A,B,C); #the vertices of the triangle Tr
CC<-circumcenter.tri(Tr) #the circumcenter
CC
D1<-(B+C)/2; D2<-(A+C)/2; D3<-(A+B)/2; #midpoints of the edges
Ds<-rbind(D1,D2,D3)
Xlim<-range(Tr[,1],CC[1])
Ylim<-range(Tr[,2],CC[2])
xd<-Xlim[2]-Xlim[1]
yd<-Ylim[2]-Ylim[1]
plot(A,asp=1,pch=".",xlab="",ylab="",main="Circumcenter of a triangle",
axes=TRUE,xlim=Xlim+xd*c(-.05,.05),ylim=Ylim+yd*c(-.05,.05))
polygon(Tr)
points(rbind(CC))
L<-matrix(rep(CC,3),ncol=2,byrow=TRUE); R<-Ds
segments(L[,1], L[,2], R[,1], R[,2], lty = 2)
txt<-rbind(Tr,CC,Ds)
xc<-txt[,1]+c(-.08,.08,.08,.12,-.09,-.1,-.09)
yc<-txt[,2]+c(.02,-.02,.03,-.06,.02,.06,-.04)
txt.str<-c("A","B","C","CC","D1","D2","D3")
text(xc,yc,txt.str)
A<-c(0,0); B<-c(1,0); C<-c(1/2,sqrt(3)/2);
Te<-rbind(A,B,C); #the vertices of the equilateral triangle Te
circumcenter.tri(Te) #the circumcenter
A<-c(0,0); B<-c(0,1); C<-c(2,0);
Tr<-rbind(A,B,C); #the vertices of the triangle T
circumcenter.tri(Tr) #the circumcenter
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.