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

Quaternion q.setFromFourVectors

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

Quaternion q.setFromFourVectors

Sat Nov 02, 2013 9:17 pm
Hello,

Currently i represent a orientation in R³ through a quaternion q.
I want to set q through a front and up vector.
They are both unit vectors and perpendicular.

A orientation with a identity quaternion (no rotation) should be

front = Vector3f::UnitX();
up = Vector3f::UnitZ();

Iam searching for a function (without trigo stuff..) who does somethink like this:

Quaternion q;
set_quaternion(&q, front_vec, up_vec);

I would appreciate some help very much!

greetings Benni
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Quaternion q.setFromFourVectors

Sat Nov 02, 2013 9:37 pm
you need to assemble the complete basis and assign it to the quaternion:
Code: Select all
Quaternionf q;
Matrix3f rot;
rot << front, up.cross(front), up;
q = rot;
bennih
Registered Member
Posts
21
Karma
0
OS

Re: Quaternion q.setFromFourVectors

Mon Nov 04, 2013 10:46 am
Thank you!

Thats it.


Bookmarks



Who is online

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