Compound Transformation: Scaling and Translation

"Mohan Parthasarathy" <[email protected]> Tue, 28 Oct 2008 10:50:34 -0800
Newsgroups gmane.games.devel.opengl
Organization Fat City Network Services, San Diego, California
Message-ID <[email protected]>
------=_Part_55881_15775312.1225216381796
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi,

I spent some time doing matrix multiplications manually and learned the
following.

- Scaling followed by translation affects how translation is done
- If scale factor is 2.0 (assume on all axis), translations will be
amplified. Hence,
  scaling followed by translation (T1) will have *larger *offset than
translation followed
  by scaling (T2)
- If scale factor is 0.25 (assume on all axis), translations will be
minimized. Hence,
  scaling followed by translation (T1) will have *smaller *offset than
translation followed
  by scaling (T2)

At least i could verify this matrix multiplications on a small rectangle.
Let me know whether the above is right. But the following program does not
demonstrate this principle.

glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glPushMatrix();
    glScalef(0.25f, 0.25f, 0.25f);
    glTranslatef(0.0f, 2.0f, -6.0f);
    DrawRect();
    glPopMatrix();

    glPushMatrix();
    glTranslatef(0.0f, 2.0f, -6.0f);
    glScalef(0.25f, 0.25f, 0.25f);
    DrawRect();
    glPopMatrix();

The first part of the code is T2 and the second part of the code is T1.
When i run this program,
i see that the second rectangle (T1) is placed higher than the first
rectangle (T2). In the second
case, the Y axis should be effectively scaled  by the scaling factor and
hence always placed
lower. At least that's what my matrix multiplication confirms. What am i
missing ? It is as though i am getting opposite results. In opengl, i am
supposed to give the compound transformations the opposite way right ? What
am i missing ?

thanks
mohan

------=_Part_55881_15775312.1225216381796
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi,<br><br>I spent some time doing matrix multiplications manually and learned the following. <br><br>- Scaling followed by translation affects how translation is done<br>- If scale factor is 2.0 (assume on all axis), translations will be amplified. Hence,<br>
&nbsp; scaling followed by translation (T1) will have <b>larger </b>offset than translation followed<br>&nbsp; by scaling (T2)<br>- If scale factor is 0.25 (assume on all axis), translations will be minimized. Hence,<br>&nbsp; scaling followed by translation (T1) will have <b>smaller </b>offset than translation followed<br>
&nbsp; by scaling (T2)<br><br>At least i could verify this matrix multiplications on a small rectangle. Let me know whether the above is right. But the following program does not demonstrate this principle.<br><br>glMatrixMode(GL_MODELVIEW);<br>
&nbsp;&nbsp;&nbsp; glLoadIdentity();<br><br>&nbsp;&nbsp;&nbsp; glPushMatrix();<br>&nbsp;&nbsp;&nbsp; glScalef(0.25f, 0.25f, 0.25f);<br>&nbsp;&nbsp;&nbsp; glTranslatef(0.0f, 2.0f, -6.0f);<br>&nbsp;&nbsp;&nbsp; DrawRect();<br>&nbsp;&nbsp;&nbsp; glPopMatrix();<br><br>&nbsp;&nbsp;&nbsp; glPushMatrix();<br>&nbsp;&nbsp;&nbsp; glTranslatef(0.0f, 2.0f, -6.0f);<br>
&nbsp;&nbsp;&nbsp; glScalef(0.25f, 0.25f, 0.25f);<br>&nbsp;&nbsp;&nbsp; DrawRect();<br>&nbsp;&nbsp;&nbsp; glPopMatrix();<br><br>The first part of the code is T2 and the second part of the code is T1.&nbsp; When i run this program,<br>i see that the second rectangle (T1) is placed higher than the first rectangle (T2). In the second<br>
case, the Y axis should be effectively scaled&nbsp; by the scaling factor and hence always placed<br>lower. At least that&#39;s what my matrix multiplication confirms. What am i missing ? It is as though i am getting opposite results. In opengl, i am supposed to give the compound transformations the opposite way right ? What am i missing ?<br>
<br>thanks<br>mohan<br><br>

------=_Part_55881_15775312.1225216381796--
----- 
FAQ and OpenGL Resources at:
  http://www.geocities.com/SiliconValley/Hills/9956/OpenGL

-- 
Author: Mohan Parthasarathy
  INET: [email protected]

Fat City Hosting, San Diego, California -- http://www.fatcity.com
---------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: [email protected] (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB OPENGL-GAMEDEV-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).