Re: Vector to rotation

Date : Wed, 15 Feb 2006 13:35:47 +0100
To : XSI(at)Softimage.COM
From : Arvid Björn <arvidbjorn(at)gmail.com>
Subject : Re: Vector to rotation
I see. I think it's a pretty bad naming convention.. =)

v1.Normalize(); should normalize itself like "InPlace" does, and
nothing else is necessary. Since it's a method of the vector object,
it should be assumed that it reffers to itself. If you want a
normalized copy you could just do this:

v2 = v1;
v2.Normalize();

that's what my c++ vector classes look like anyway ;-) "Place" is
confusing, people are lead to believe it reffers to a coordnate, while
- as you say - vectors don't have them, they're just a direction. It
should at least be named "NormalizeSelf" or something along those
lines.

IMO =)

--
stockholm.postproduction | www.stopost.se

On 2/15/06, kim aldis <kim(at)cg-soup.com> wrote:
>
> A vector - it's a vector, not a normal, a normal is usually used to describe
> a vector perpendicular to something, usually a surface - is a direction only
> so it doesn't have a 'tail' position. Nor does it have a coordinate. it's an
> important distinction.
>
> How helpful the documentation is when it's so wonderfully literal ;-)
> Although to be fair, the difference between Normalize and Normalize in
> place, is just that, one normalizes in place, the other doesn't, it just
> needs a bit more detail.
>
> Given vectors v1 and v2:
>
> v1.Normalize( v2 ); // normalize v2 and place the result in v1
>
>
> v1.NormalizeInPlace(); // normalize v1 and place the result in v1.
>
>
> Normalize divides the 3 components of the vector by the vector length.
>
> l = sqrt(  x*x + y*y + z*z );
>
> x /= l;
> y /= l;
> z /= l;
>
>
>
>
>
>
>  ________________________________
>  From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of
> guillaume laforge
> Sent: 15-February-2006 08:49
> To: XSI(at)Softimage.COM
> Subject: Re: Vector to rotation
>
>
> I guess normalize is a one unit length vector with the tail at 0,0,0 and
> normalize in place is a one unit length vector with the tail at the same
> coordinate than the non-normalized vector.
>
> Cheers
>
> Guillaume Laforge
>
>
>
> On 2/15/06, Arvid Björn <arvidbjorn(at)gmail.com> wrote:
> > 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
> >
>
>

---
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.