|
Re: how to get scale info from a transform matrix? [message #47598 is a reply to message #47531] |
Tue, 21 February 2006 14:13   |
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   |
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
|
|
|
|