Thanks, I had it sorted, but your function is indeed useful for other
things, thanks for sharing :-)
Just a question though, what's the difference between Normalize and
NormalizeInPlace, the SDK doc offers this detailed description:
----8<-----------
Description
Normalizes this vector in place.
--------->8------
:-P
--
stockholm.postproduction | www.stopost.se
On 2/15/06, Derek Jenson <derekjenson(at)hotmail.com> wrote:
> Here is a function I created for getting a rotation from 2 objects. Feel
> free to use it if you find it helpful.
>
> Pass a Direction Object, an Up Vector Object, and the pass strings for
> which axis you want to point at the Direction Object and which axis to point
> toward your Up Vector Object ("x", "y", or "z"). Negatives axis aren't
> considered, but you can add those if needed. The function returns an
> SIRotation object.
>
> function RotFromObj (dirObj, upObj, majorAxis, minorAxis)
> {
> var dirVec, upVec, crossVec;
> var m3, rot;
> var X, Y, Z;
>
> dirVec = XSIMath.CreateVector3();
> upVec = XSIMath.CreateVector3();
> crossVec = XSIMath.CreateVector3();
>
> dirObj.Kinematics.Global.Transform.GetTranslation(dirVec);
> upObj.Kinematics.Global.Transform.GetTranslation(upVec);
>
> dirVec.NormalizeInPlace();
> upVec.NormalizeInPlace();
> crossVec.Cross(upVec, dirVec);
> crossVec.NormalizeInPlace();
> upVec.Cross(dirVec, crossVec);
> upVec.NormalizeInPlace();
>
> var X, Y, Z;
>
> switch(majorAxis + minorAxis)
> {
>
> case "xy":
> X = dirVec;
> Y = upVec;
> crossVec.NegateInPlace();
> Z = crossVec;
> break;
>
> case "xz":
> X = dirVec;
> Y = crossVec;
> Z = upVec;
> break;
>
> case "yx":
> X = upVec;
> Y = dirVec;
> Z = crossVec;
> break;
>
> case "yz":
> crossVec.NegateInPlace();
> X = crossVec;
> Y = dirVec;
> Z = upVec;
> break;
>
> case "zx":
> X = upVec;
> crossVec.NegateInPlace();
> Y = crossVec;
> Z = dirVec;
> break;
>
> case "zy":
> X = crossVec;
> Y = upVec;
> Z = dirVec;
> break;
>
> default:
> X = crossVec;
> Y = upVec;
> Z = dirVec;
> }
>
> m3 = XSIMath.CreateMatrix3();
>
> m3.Set(X.x, X.y, X.z,
> Y.x, Y.y, Y.z,
> Z.x, Z.y, Z.z);
>
> rot = XSIMath.CreateRotation();
> rot.SetFromMatrix3(m3);
>
> return(rot);
> }
>
>
> Hope this helps,
>
> Derek Jenson
>
>
>
>
>
>
> >From: Arvid Björn <arvidbjorn(at)gmail.com>
> >Reply-To: XSI(at)Softimage.COM
> >To: xsi(at)Softimage.COM
> >Subject: Vector to rotation
> >Date: Thu, 9 Feb 2006 12:06:50 +0100
> >
> >Hey,
> >
> >Are there any built-in methods for converting a 3-dimensional vector
> >to xyz-rotation angles in XSI?
> >
> >-a
> >
> >--
> >stockholm.postproduction | www.stopost.se
> >
> >---
> >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