rotation shmotation
October 23, 2006 4:37 PM
Subscribe
Vector Geometry Filter: I'm working in matlab and need to transform a surface to match an arbitrary angle. I have the unit vector of the new normal (and the original normal is in the Z axis (0 0 1))...however i'm not sure how to rotate one normal to another (i know, i know, it sounds very simple really...)
So the real problem is that the orders of rotation cannot be mixed around. Matlab allows you to rotate a surface using an angle of rotation and an arbitrary vector...so theoretically i could find a single axis and angle that would allow me to do the rotation in one operation (and thus get rid of the orders), but i'm finding the math is a beyond my head. I've also tried transforming the original data to a new plane but matlab isn't soo happy with that technique (and i've had a hard time tracking down a good equation for that as well). Any suggestions would be much appreciated....help me obi wan kenobe, you're my only hope.
posted by NGnerd to science & nature (5 comments total)
In MATLAB, try this:
function newr = rotateIt(vectorToBeRotatedAbout, angle, vectorToBeRotated)
r = vectorToBeRotated;
n = vectorToBeRotatedAbout;
newr = r*cos(angle) + n*dot(n,r)*(1-cos(angle)) + cross(r,n)*sin(angle);
posted by Upton O'Good at 4:57 PM on October 23, 2006