This forum has been archived. All content is frozen. Please use KDE Discuss instead.

quaternion, slerp

Tags: None
(comma "," separated)
bennih
Registered Member
Posts
21
Karma
0
OS

quaternion, slerp

Mon Oct 28, 2013 2:41 pm
Hello,

I've wrote a simple programm:


#include <iostream>
#include "../Eigen/Geometry"

using namespace Eigen;

int main(void)
{
Vector3f a(1,0,0), b(0,1,0), c(1,1,0);
Quaternionf q1, q2;
q1.setFromTwoVectors(a,b);
q2.setFromTwoVectors(a,c);

std::cout << "\n" << q1.slerp(1, q2).toRotationMatrix().eulerAngles(2,1,0) << "\n";
std::cout << "\n" << q2.slerp(1, q1).toRotationMatrix().eulerAngles(2,1,0) << "\n";
return 0;
}

output:
0.785398
-0
0

1.5708
-0
0

My expected output:

-0.785398
-0
0

+0,785398
-0
0


I thought a slerp rotates one rotation into another, but in this case it didnt happen.
The first slerp rotates the orientation away and not into the secound orientation.

i thought it works dimilar to Quaternion q; q.setFromTwoVectors(...);

The problem is, i didnt find much information about slerps..
I dont want to go that deep in quaternions, I just want to use them to represent a orientation.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: quaternion, slerp

Mon Oct 28, 2013 3:22 pm
The results are correct. q1 represents a rotation of pi/2=1.57 around z and q2 a rotation of pi/4=0.78 around z. So q1.slerp(1, q2) returns q2 exactly, and q2.slerp(1, q1) returns q1 exactly.
bennih
Registered Member
Posts
21
Karma
0
OS

Re: quaternion, slerp

Mon Oct 28, 2013 5:15 pm
Hello,

iam searching for something like a rotation difference.
So if q1 is pi/2 around z and q2 ist pi/4 around z I iam looking for the -pi/4 to rotate q1 into q2.
How can i manage that?
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: quaternion, slerp

Mon Oct 28, 2013 5:23 pm
You have to think in term of concatenation of transformations: you cancel one and apply the second:

q2*q1.inverse()

see also: viewtopic.php?f=74&t=117791
bennih
Registered Member
Posts
21
Karma
0
OS

Re: quaternion, slerp

Mon Oct 28, 2013 5:57 pm
Ha thats it!

Yes I've understood it in context to Matrices.
Iam totally new to Quaternions and didnt know that it works the same way.

Thank you!


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]