Registered Member
|
Hello!
Currently iam writing my Bachelor Thesis in Electronical Engineering and i had to program with Eigen. I use Eigen mostly for geometric transformations in R³ space. I represent a orientation by 2 vectors. A front and a up vector (i think similar to the viewpoint in openGL). They are normalized, perpendicular and have their coordinate origin at (0,0,0) Everythink works fine so far. My Problem is, i had to write a function, which returns the difference between 2 orientations. The best thing would be a rotations matrix, which transforms the first orientation into the other, but i have really no clue how to get this rotation matrix. Is there a common algorithm or function i have overseen? Thanks for any help! Greetings |
Moderator
|
Form your full basis into 3x3 matrices B1 and B2, and then what your are looking for is simply B2 * B1.transpose().
|
Registered Member
|
Hi,
thats not exactly what i was looking for. But thank you anyway! good support here. But I've solved my problem. Greetings |
Moderator
|
hm, then please post your solution.
|
Registered Member
|
no problem.
I divide the difference between 2 orientation into 2 rotations. The first rotates the front vector of orientation1 into the front vector of orientation2. For this I use "AngleAxis". I get the angle from the dot product of the front vectors (change formula to the angle). And I get the axis to rotate from the cross product of the front vectors. After the front vectors of orientation1 and orientation2 are in the same position i do the same thing with the upvector. Finally i multiply the two rotations and i get the transformation to transform orientation1 into orientation2. Sry for my bad english. Iam from germany |
Moderator
|
ok, then I well understood your question and my solution is simpler and faster (no trigo):
|
Registered Member
|
Thank your sir!
Your solution is much better! could you post a link (wikipedia or something), where I can understand your formula. I would like to understand why this works. greetings |
Moderator
|
You have to understand what a basis is an that a unitary (or orthonormal) basis is the same as a rotation matrix. For instance, the matrix R1 stores as column your basis (up,front,left)_1. R1 * p transforms a point p expressed in your basis into the world space Since R1 is orthonormal, you can see it as the rotation that transforms the basis 1,0,0 ; 01,0 ; 0,0,1 to (up,front,left)_1. So to get the rotation difference between your two bases you simply cancel the first one and then apply the second one. Also recall that for a unitary matrix, its inverse is simply its transpose. Hope that helps.
|
Registered Member
|
After reading some articles and watching some youtube videos about it, I understand it well enough to handle it.
Thank for your advice! |
Registered users: Baidu [Spider], Bing [Bot], Google [Bot]