11-04-2004, 12:46 PM
Hi Im new to using OpenGl. I need to perform a shear translation on a 2D Graphic along the x axis.
I have found the following matrix but im not sure how to implement it within my code.
1 h 0;
0 1 0;
0 0 1;
Any help with this would be much appreciated.
Sheering, in 3D, incidentally is defined:
| 1 Kxy Kxz 0 |
| 0 1 Kyz 0 |
| 0 0 1 0 |
| 0 0 0 1 |The subscripts on K define the plane for the sheering. (I think)
Remember, OpenGL uses homogeneous coordinates, so there is actually 4X4.
How to apply it? Well, OpenGL has a glMultMatrix() function that can be used.
OGL represents matrices as float or double arrays, see THE RED BOOK (http://fly.cc.fer.hr/~unreal/theredbook/appendixg.html) for details.
Basically, it might go something like this:
double xySheer, xzSheer, yzSheer;
memset( sheerMatrix, 0, 16 * sizeof(double) );
sheerMatrix = sheerMatrix =
sheerMatrix = sheerMatrix = 1.0;
sheerMatix = xySheer;
sheerMatix = xzSheer;
sheerMatix = yzSheer;
glMatrixMode( GL_MODELVIEW );
glMultMatrixd( sheerMatrix );
// Draw sheered geometry
glPopMatrix();Hope that helps
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.