# How does vrrotvec calculate rotation?

33 views (last 30 days)
Michael McGeehan on 17 Nov 2021
Commented: Michael McGeehan on 17 Nov 2021
Can anybody describe the math behind vrrotvec? The documentation for this function is very sparse and I would like to know how the rotational transformation is being calculated for my own confiendence in my code.
Thanks!

James Tursa on 17 Nov 2021
It is a simple algorithm that uses the cross product for the axis (normalized), and the dot product is used to calculate the angle. I.e., vrrotvec(x,y) is equivalent to the following (but with error checking etc.)
rotation axis = cross(x,y)/norm(cross(x,y))
rotation angle = acos(dot(x,y)/(norm(x)*norm(y)))
then these are concatenated into a 4-element vector
Michael McGeehan on 17 Nov 2021
@James Tursa makes sense. Thanks!

### Categories

Find more on Plot Customization in Help Center and File Exchange

R2020b

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!