File: trisplinter.R

package info (click to toggle)
r-cran-geometry 0.3-6%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,184 kB
  • sloc: ansic: 366; xml: 202; sh: 13; makefile: 5
file content (10 lines) | stat: -rw-r--r-- 307 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
"trisplinter" <-
function(T,p,threshold=sqrt(.Machine$double.eps)){
  rownorm2 = function(x) drop(sqrt((x^2)%*%c(1,1)))
  d1 = p[T[,1],] - p[T[,2],]
  d2 = p[T[,2],] - p[T[,3],]
  d1 = d1 / rownorm2(d1)
  d2 = d2 / rownorm2(d2)
  ar = d1[,1]*d2[,2] - d1[,2]*d2[,1]
  return(abs(ar) < threshold)
}