RE: [script][5.11] Get difference between 2 rotations

Date : Fri, 5 Oct 2007 09:37:08 +0100
To : <XSI(at)Softimage.COM>
From : "Brent McPherson" <brentmc(at)Softimage.COM>
Subject : RE: [script][5.11] Get difference between 2 rotations
Bernard,

You should also check out Michael Isner's quaternion spells page since
it has lots of script examples for dealing with rotations in XSI.

In particular section 10 on subtracting rotations is pretty much what
you are trying to do.

http://www.isner.com/tutorials/quatSpells/quaternion_spells_14.htm

Aside: I just noticed on Michael Isner's page he has the order of
quaternion multiplication reversed from what I suggested. Even though I
am an XSI dev I don't do that much scripting in the OM so perhaps the
order of quaternion multiplication in the OM is reversed from what I
expected. I guess you will just have to try out both and see which one
works.

  Aquat.InvertInPlace
  Cquat.Mul Aquat, Bquat
            ^^^^^^^^^^^^
Old CG proverb: "If at first you don't succeed, try reversing the order
of your operations!" ;-)
--
Brent 

-----Original Message-----
From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf
Of Brent McPherson
Sent: Thursday, October 04, 2007 9:48 PM
To: XSI(at)Softimage.COM
Subject: RE: [script][5.11] Get difference between 2 rotations

Bernard,

I'm afraid Nicholas' solution is wrong.

To find a true delta rotation you must multiply quaternions as Martin
suggested, not subtract them.

However, it also looks to me like there is a small typo in Martin's
solution and it should be:

   startQuat.InvertInPlace()
   ^^^^^^^^^
   deltaQuat.Mul(endQuat,startQuat)

Cheers!
--
Brent

-----Original Message-----
From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf
Of Bernard Lebel
Sent: Thursday, October 04, 2007 9:14 PM
To: XSI(at)Softimage.COM
Subject: Re: [script][5.11] Get difference between 2 rotations

All right thanks everyone, I'll see what I can from there.

Cheers!
Bernard




On 10/4/07, Nicolas Langlois <nicolasl(at)buzzimage.com> wrote:
> Bernard,
>
> Maybe something like this:
>
> # PYTHON CODE
>
> import win32com.client
> from win32com.client import constants
> from win32com.client import Dispatch
> XSIMath    = Dispatch('XSI.Math')
>
> # Get the items Transforms
> oItemATransform = oItemsA.Kinematics.Global.Transform
> oItemBTransform = oItemsB.Kinematics.Global.Transform
> oItemCTransform = oItemsA.Kinematics.Global.Transform
> oRotA = XSIMath.CreateRotation()
> oRotB = XSIMath.CreateRotation()
> oRotC = XSIMath.CreateRotation()
> oItemATransform.GetRotation(oRotA)
> oItemATransform.GetRotation(oRotB)
>
>
> #Create Quaternions.
> oRotA.GetQuaternion(q1)
> oRotB.Quaternion(q2)
>
> #q1 = q1 - q2
> q1.SubInPlace(q2)
> oRotC.SetFromQuaternion(q1)
>
> oItemCTransform.SetRotation(oRotC)
> oItemsC.Kinematics.Global.Transform = oItemCTransform
>
>
> # END PYTHON CODE
>
> Nicolas Langlois
> Senior/Lead Rigger/TD
> Buzz Image
>
>
>
> Bernard Lebel wrote:
> > Hello,
> >
> > I'd need some guidance here. Say I have 3 objects. I want the third
> > object to get the rotational difference between the first two.
> >
> > In a simplified example, the first object has rotx 25.0, the second
> > has rotx 15.0, so I'd want the third object to get rotx of 10.0.
> >
> > I'm not sure at all where to go from there, using the XSI math
> > objects. Do I have to perform a subtraction for every axis of the
> > rotation?
> >
> >
> > Thanks
> > Bernard
> > ---
> > Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in
body:
> > unsubscribe xsi
> >
> ---
> Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in
body:
> unsubscribe xsi
>
---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in
body:
unsubscribe xsi

---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in
body:
unsubscribe xsi

---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.