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 
Return to the default flat view Create a new topic Submit Reply
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 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
[Message index]
 
Read Message
Read Message
Read Message
Read Message
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: Sat Oct 11 05:57:09 PDT 2025

Total time taken to generate the page: 0.95984 seconds