Question by
BenT39 · Nov 04, 2016 at 04:55 PM ·
rotationquaternionrotationsopencv
Convert rotation vector or matrix to Quaternion
Hi, I have a rotation vector in opencv and would like to apply that rotation to a game object. I have the rotation matrix as well (given by Rodrigues) if that helps. I tried various approaches, like this but nothing helped. Any idea on how to achieve this?
Comment
Best Answer
Answer by BenT39 · Nov 05, 2016 at 02:42 PM
Hi, I just saw that the rotation vector is an angle-axis representation, just a litte different. I was able to figure out how to translate it to angle-axis and use Quaternions static AngleAxis function to get to my Quaternion:
float theta = (float)(Math.Sqrt(m.xr*m.xr + m.yr*m.yr + m.zr*m.zr)*180/Math.PI);
Vector3 axis = new Vector3 (m.xr, m.yr, m.zr);
Quaternion rot = Quaternion.AngleAxis (theta, axis);
Your answer
Follow this Question
Related Questions
How to get Quaternion from Transition Matrix 0 Answers
Know when the object is rotated? 1 Answer
Questions about Rotations in unity 1 Answer