realbasic-games
[Top] [All Lists]

Setting quaternions by way of "=" or copying them

To: realbasic-games at lists dot realsoftware dot com
Subject: Setting quaternions by way of "=" or copying them
From: "Heinz J. Gattringer" <heinzjos at uio dot satnet dot net>
Date: Mon, 21 Feb 2005 23:54:02 -0500
Delivered-to: realbasic-games at lists dot realsoftware dot com
References: <20050220180020 dot A4A5773F10F at lists dot realsoftware dot com>
Hello again,

More questions born out of my dabblings into 3D programming. I noticed that when dealing with vectors that represent the position of an Object3D (say Object3D1.Position) like this:
Object3D2.Position=Object3D1.Position
both vectors remain sort of "coupled", that is, when you later change the position of Object3D2 (by way of Object3D2.MoveForward for example), the position of Object3D1 changes in exactly the same manner automatically. This is a neat thing, which I exploit profusely in my game. And when you do not want that to happen, you can use following build-in statement:
Object3D2.Position.copy Object3D1.position
This way you get independent vectors, where you can change the position of one without affecting the other. Very convinient, too.

Now, something similar happens with quaternions. When you set one quaternion this way:
Object3D2.Orientation=Object3D1.Orientation
They remain "coupled" and when you change the orientation of one of the objects, the orientation of the other is changed as well. This is practical sometimes. But when I want to get independent orientations, I have found no other way to do this than the clumsy:
Object3D2.Orientation.W=Object3D1.Orientation.W
Object3D2.Orientation.X=Object3D1.Orientation.X
Object3D2.Orientation.Y=Object3D1.Orientation.Y
Object3D2.Orientation.Z=Object3D1.Orientation.Z

Is there a nicer and more efficient way to copy one quaternion to another without having them "coupled"?

Thanks
Heinz Jose

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>