R/distancePointToPlane.R

Defines functions distancePointToPlane

Documented in distancePointToPlane

distancePointToPlane <- function(p, n, q){
	# http://mathworld.wolfram.com/Point-PlaneDistance.html
	# q is a point in the plane

	if(is.matrix(p)){
		if(nrow(p) > 1){
			d <- rep(NA, nrow(p))
			for(i in 1:nrow(p)){
				d[i] <- sum((n*-(q - p[i, ])))  / sqrt(sum(n^2))
			}
			return(d)
		}
	}

	sum((n*-(q - p)))  / sqrt(sum(n^2))
}

Try the StereoMorph package in your browser

Any scripts or data that you put into this service are public.

StereoMorph documentation built on May 25, 2022, 5:06 p.m.