Graphics Programs Reference
In-Depth Information
Projection transformation allows control of the projection of cube world of NDCS
( Figure 3-17 ) onto the (rectangular) 2D space of the display screen. This helps re-
move the skewing of rendered graphics (since we limit the viewing volume, graphics
no longer stretch when the orientation changes). Additionally, the final coordinate
system becomes right handed (that is, point (0, 0, 1) in this coordinate system
is closer to the viewer than point (0, 0, -1) ).
The Matrix Class
Most graphic rendering APIs do not provide built-in functions for transformations.
However, frameworks hosting such APIs do provide utility methods for the same.
Once again, Android comes to the rescue, providing useful methods for transform-
ations using the android.opengl.Matrix class (not to be confused with the
android.graphics.Matrix class). The following is a list of matrix math util-
ities from this class to help easily perform the transformations discussed so far:
Geometric/Modeling transformation
Matrix .translateM(float[ ] m, int mOffset, float x, float y, float z):
Translates matrix m by x , y, and z along x-axis, y-axis, and z-ax-
is, respectively (please note that, for all methods we use from the
Matrix class, we set the mOffset argument as '0,' which
means “no-offset”)
Matrix .rotateM(float[ ] m, int mOffset, float a, float x, float y,
float z): Rotates matrix m by angle a (in degrees) about the speci-
fied axes
Matrix .scaleM(float[ ] m, int mOffset, float x, float y, float z):
Scales matrix m by x , y, and z along x-axis, y-axis, and z-axis,
respectively
Coordinate/Viewing transformation
Matrix .setLookAtM(float[ ] m, int mOffset, float eyeX, float eyeY,
float eyeZ, float centerX, float centerY, float centerZ, float upX,
float upY, float upZ): Defines a view matrix m in terms of an eye
point (that is, viewer's position), a center of view, and an up vec-
tor.
Search WWH ::

Custom Search