R/rotateBody.R

Defines functions rotateBody

Documented in rotateBody

rotateBody <- function(m, p, v, a){

	if(is.vector(m)) m <- matrix(m, nrow=1, ncol=length(m))

	# IF INPUT MATRIX HAS NO ROWS, RETURN EMPTY MATRIX
	if(dim(m)[1] == 0) return(m)

	# GET TRANSLATION MATRIX
	tm <- matrix(p, nrow=nrow(m), ncol=ncol(m), byrow=TRUE)

	# MAKE ROTATION POINT ORIGIN
	m <- m - tm

	# FIND ROTATION MATRIX
	RM <- tMatrixEP(v=v, a=a)
	
	# ROTATE POINTS
	m <- m %*% RM

	# MOVE POINTS BACK TO ORIGINAL POSITION
	m <- m + tm
	
	m
}

Try the linkR package in your browser

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

linkR documentation built on May 2, 2019, 2:14 p.m.