RotatePoint.m 418 B

12345678910111213
  1. % RotatePoint.m
  2. %
  3. % Rotates a point by multiplying from the left with the provided rotation matrix.
  4. function rotVec = RotatePoint(rot, vec)
  5. if (size(vec,2) > size(vec,1))
  6. vec = vec';
  7. end
  8. assert(size(vec,1) == 3 && size(vec,2) == 1, 'Vector should have exactly 3 elements');
  9. assert(size(rot,1) == 3 && size(rot,2) == 3, 'Rotation matrix has incorrect dimensions');
  10. rotVec = rot * vec;
  11. end