R/get.rotation.matrix.R

get.rotation.matrix = function(a, b) {
  # Returns the 3x3 matrix that rotates a in to b
  a = norm(cbind(a))
  b = norm(cbind(b))
  dab = dot(a, b)
  ncab = magnitude(cross(a,b))
  G = rbind(c(dab, -ncab, 0), c(ncab, dab, 0), c(0, 0, 1))
  F = cbind(a, norm(b-dab*a), cross(b,a))
  return (F %*% G %*% solve(F))
}

Try the eggs package in your browser

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

eggs documentation built on May 2, 2019, 5:23 p.m.