Re: scale retrieval

New Message Reply Date view Thread view Subject view Author view

From: Bram Stolk (bram++at++sara.nl)
Date: 03/12/2001 03:47:53


Mark Evans wrote:
>
> Is it possible to retrieve the rotation, translation
> and scale for a pfDCS ( or pfSCS) separately? You can

yes,

to get orientation of matrix m:

pfQuat q;
m.getOrthoQuat(q);

to get translation:

pfVec3 t;
m.getRow(3, t);

to get scale in x-direction:
pfVec3 r;
m.getRow(0, r);
float scale = r.length()

> set separately the translation, rotation and scale for
> a pfDCS (through pfDCSTrans, pfDCSRot, pfDCSScale,
> pfDCSScaleXYZ), but you can only retrieve the matrix
> of a pfDCS (pfGetDCSMat). Is it possible to retrieve,
> from this matrix, the translation, rotation and scale?
> I've tried to use pfGetOrthoMatCoord, but it would
> only get me the translation and rotation, not the
> scale.
> Is there a unique solution, or could different
> rotations+scales to give the same result?
> Also, if I want to "animate" a pfDCS from pfMatrix m1
> to pfMatrix m2 through linear interpolation, is it
> correct to linearly interpolate each of the 16
> coefficients of the matrix for the pfDCS between the

Absolutely not.

> source and destination matrices? Is there a better (or
> correct) way?

You need to extract the scale, orient, and translation
seperately, and interpolate them seperately.

quaternions have ::slerp (linear interpolation) and
also quadratic. However, I could not get the quadratic
interpolation of pfQuats to work properly. Not sure if
this is a performer problem, or a fault in my code.

scalars and vectors can be interpolated quite simply,
both linearly, and with splines.

For my apps, I use hermite splines to interpolate scalars
and vectors. For quats, I use ::slerp().

After interpolation of the 3 components, you need to
reassemble them into a single matrix. I use this
code to do this:

void TransformAnimator::Evaluate(float time)
{
  pfVec3 p = PosInterp.Evaluate(time);
  pfQuat q = OriInterp.Evaluate(time);
  float s=1.0;
  if (SclInterp.GetEventCount())
   s = SclInterp.Evaluate(time);
  pfMatrix m;
  m.makeQuat(q);
  m.setRow(3,p);
  if (s!=1.0)
    m.preScale(s,s,s,m);
  TargetDCS.setMat(m);
}

PosInterp, SclInterp and OriInterp are my custom classes,
and do the interpolation of vectors, scalars and quats.

Note: I assume uniform scaling.
Personally I think non-uniform-scaling is really bad, and you
should not use it at all.

  Bram Stolk

 
> __________________________________________________
> Do You Yahoo!?
> Get email at your own domain with Yahoo! Mail.
> http://personal.mail.yahoo.com/
> -----------------------------------------------------------------------
> List Archives, FAQ, FTP: http://www.sgi.com/software/performer/
> Open Development Project: http://oss.sgi.com/projects/performer/
> Submissions: info-performer++at++sgi.com
> Admin. requests: info-performer-request++at++sgi.com

-- 
------------------------------------------------------------------------------
 Bram Stolk, VR Specialist.
 SARA Academic Computing Services Amsterdam, PO Box 94613, 1090 GP  AMSTERDAM
 email: bram++at++sara.nl   Phone +31-20-5923059  Fax +31-20-6683167

"I heard if you play the NT-4.0-CD backwards, you get a satanic message." "Thats nothing, if you play it forward, it installs NT-4.0" ------------------------------------------------------------------------------


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2b29 : Mon Mar 12 2001 - 03:47:58 PST

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.