comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » how to get scale info from a transform matrix?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
how to get scale info from a transform matrix? [message #47531] Sun, 12 February 2006 23:28 Go to next message
Weihua FANG is currently offline  Weihua FANG
Messages: 26
Registered: January 2006
Junior Member
Hi,

Can someone show me how to get scale info of x, y, z axis from the
transform matrix of a IDLgrModel?

thank you.

Fang
Re: how to get scale info from a transform matrix? [message #47598 is a reply to message #47531] Tue, 21 February 2006 14:13 Go to previous messageGo to next message
Karl Schultz is currently offline  Karl Schultz
Messages: 341
Registered: October 1999
Senior Member
On Tue, 21 Feb 2006 11:14:49 -0800, Rick Towler wrote:

>
>
> Weihua FANG wrote:
>
>> Can someone show me how to get scale info of x, y, z axis from the
>> transform matrix of a IDLgrModel?
>
> You can really only do this for models that haven't been rotated. A 4x4
> scale matrix is defined as:
>
> Sx 0 0 0
> 0 Sy 0 0
> 0 0 Sz 0
> 0 0 0 1
>
> Where Sx, Sy, and Sz are the x, y and z axis scaling factors
> respectively. So:
>

See:

Thomas, Spencer W., Decomposing a Matrix Into Simple Transformations,
Graphics Gems II, p. 320-323, code: p. 599-602, unmatrix.c.

http://www.acm.org/pubs/tog/GraphicsGems/gemsii/unmatrix.c

If there is no shear or perspective, then getting the scale factors
amounts to just taking the length of the column vectors.

Karl
Re: how to get scale info from a transform matrix? [message #47602 is a reply to message #47531] Tue, 21 February 2006 11:14 Go to previous messageGo to next message
Rick Towler is currently offline  Rick Towler
Messages: 821
Registered: August 1998
Senior Member
Weihua FANG wrote:

> Can someone show me how to get scale info of x, y, z axis from the
> transform matrix of a IDLgrModel?

You can really only do this for models that haven't been rotated. A 4x4
scale matrix is defined as:

Sx 0 0 0
0 Sy 0 0
0 0 Sz 0
0 0 0 1

Where Sx, Sy, and Sz are the x, y and z axis scaling factors
respectively. So:

DL> oModel=OBJ_NEW('IDLgrModel')
IDL> print, oModel->GetCTM()
1.0000000 0.00000000 0.00000000 0.00000000
0.00000000 1.0000000 0.00000000 0.00000000
0.00000000 0.00000000 1.0000000 0.00000000
0.00000000 0.00000000 0.00000000 1.0000000
IDL> oModel->Scale, 0.5, 0.5, 0.5
IDL> ctm = oModel->GetCTM()
IDL> print, ctm
0.50000000 0.00000000 0.00000000 0.00000000
0.00000000 0.50000000 0.00000000 0.00000000
0.00000000 0.00000000 0.50000000 0.00000000
0.00000000 0.00000000 0.00000000 1.0000000
IDL> print, ctm[0,0], ctm[1,1], ctm[2,2]
0.5000000 0.5000000 0.5000000
IDL> oModel->Scale, 4.0, 4.0, 4.0
IDL> ctm = oModel->GetCTM()
IDL> print, ctm
2.0000000 0.00000000 0.00000000 0.00000000
0.00000000 2.0000000 0.00000000 0.00000000
0.00000000 0.00000000 2.0000000 0.00000000
0.00000000 0.00000000 0.00000000 1.0000000
IDL> print, ctm[0,0], ctm[1,1], ctm[2,2]
2.0000000 2.0000000 2.0000000


Because rotation matrices apply to some of the same elements of the
transform matrix you can't easily determine what scaling was applied in
order to scale, and what "scaling" has been applied due to a rotation.

IDL> oModel -> Rotate, [0,1,0], 30.
IDL> ctm= oModel->GetCTM()
IDL> print, ctm
1.7320508 0.00000000 1.0000000 0.00000000
0.00000000 2.0000000 0.00000000 0.00000000
-1.0000000 0.00000000 1.7320508 0.00000000
0.00000000 0.00000000 0.00000000 1.0000000
IDL> print, ctm[0,0], ctm[1,1], ctm[2,2]
1.7320508 2.0000000 1.7320508

You can work around this by using separate scale and rotation models.


One last thing to note, the *COORD_CONV keywords to the IDLgr objects
are an additional scaling factor that is applied to your data before any
other transformations. If you need to know exactly what scaling has
been applied to your data you need to consider these as well.

-Rick
Re: how to get scale info from a transform matrix? [message #47811 is a reply to message #47598] Mon, 06 March 2006 23:49 Go to previous message
Weihua FANG is currently offline  Weihua FANG
Messages: 26
Registered: January 2006
Junior Member
Hi, Karl and Rick ,

Thank you for your detailed information. I played some tricks and got a
workaround.

FANG
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Fractional Pixels Origin?
Next Topic: Plot sphere and ellipsoid(oblate,prolate,triaxial) by object graphics

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 04:06:22 PDT 2025

Total time taken to generate the page: 1.84078 seconds