Description Usage Arguments Examples
computes the orientation of a triangle
1 |
s |
a 3x2 numeric matrix, representing a triangle. Each row of the matrix are the coordinates of an extreme point of the triangle. |
1 2 3 4 5 6 7 | zz<-function(p){
s=matrix(sample(0:4,6,rep=T),3,2)
plot(s[c(1:3,1),],type="l",main=if(triangleorientation(s)==1){"+"}else{if(triangleorientation(s)==-1){"-"}else{"aligned"}},xlim=c(-1,5),ylim=c(-1,5),xlab="",ylab="",xaxt='n', yaxt='n')
text(s[,1],s[,2],toupper(letters[1:3]),cex=1,col="red")
}
par(mfrow=c(2,2),mar=c(5,3,2,2))
set.seed(7);replicate(4,zz(c(sample(-2:3,1),sample(-2:2,1))))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.