Quaternion * Vector3 ??

kikosmalltalk

06-03-2008 19:08:49

Hi everyone

How ago the operation * between a quaternion and a vector3?
Apologize if it is not the suitable forum, but there is not a forum of general discucion

best regard kiko

bharling

07-03-2008 09:55:28

This will probably help you :

http://www.ogre3d.org/wiki/index.php/Quaternion_and_Rotation_Primer

basically:

quaternion * vector = vector rotated by the quaternion.

kikosmalltalk

08-03-2008 13:52:58

Hi

Thank you for reply.
It is the same as to make this:

geXForm3dRotate: pM by: pV into: pResult
" Result is Matrix M * Vector V: V Rotated by M (no translation). "

<api: geXForm3d_Rotate struct struct struct none>
^self invalidArgument

kiko

bharling

08-03-2008 23:26:05

Hmm...

Sorry I'm not sure what you mean. Can you explain a bit more? Is it a quaternion or a matrix multiplication you need to know about?

If your question is about Genesis3D then you'll need to ask at that forum instead of here, but I guess that you're a genesis3D user just starting with Ogre?

kikosmalltalk

09-03-2008 13:33:15

Hi

you wrote:
Sorry I'm not sure what you mean. Can you explain a bit more? Is it a quaternion or a matrix multiplication you need to know about?


A rotation matrix and a quaternion represent the same thing. Right ?
I want to have an equivalent one (Quaternion * Vector) with a (matrix * Vector).

At the moment I use Genesis3D and Smalltalk MT, but in the future I would be interested to use Ogre3D.
The only problem for this is that Ogre3D doesn't have a version as Genesis3D.
That is to say, Genesis3D is a classic DLL in C. Not C++.

The only way would be, to have a version of Ogre as Genesis3D or a scripting interface as has phyton.
The problem is that my knowledge of C/C++ are very basic as so that I can make this.

At this time I am trying to implement a code Ogre with Genesis3D.
I hope my preguta is not bothersome for the community of Ogre

(matrix * vector = vector rotated by the matrix) = (quaternion * vector = vector rotated by the quaternion). Right ?

kiko

bharling

13-03-2008 21:48:15

No not bothersome at all, we try to help if we can :)

Trouble is, I dont really know much about matrices, I can just about deal with quaternions but matrices are a bit beyond me i'm afraid.

I think you're right though, a quaternion and rotation matrix do basically the same thing. Heres a bit of code I nicked from nullsquared ( who may well be a child genius - check out his stuff in the showcase forum .. )


Ogre::Quaternion makeQuat(
const Ogre::Vector3 &forward, const Ogre::Vector3 &wantedUp = Ogre::Vector3::UNIT_Y) {
// if you don't understand this, don't worry
// just basically makes a full orientation based
// on a desired "up" vector and a desired "forward" vector
Ogre::Vector3 right = wantedUp.crossProduct(forward).normalisedCopy();
Ogre::Vector3 up = forward.crossProduct(right).normalisedCopy();
return Ogre::Quaternion(right, up, forward);
}


the python version of this would be:

def makeQuat( wantedForward, wantedUp):
right = wantedUp.crossProduct( wantedForward ).normalisedCopy()
up = wantedForward.crossProduct( right ).normalisedCopy()
return ogre.Quaternion( right, up, forward )


you'd then use this quaternion to rotate your original vector to face the new direction, by doing newQuaternion * originalVector

kikosmalltalk

25-03-2008 16:39:54

Hi

Thank you.
I will ask again if I have some other question.

KIKO