Module 2-2
Module 2-2
Module 2-2
𝑷′ 𝒙 𝑷𝒙 + 𝒕𝒙
=
𝑷′ 𝒚 𝑷𝒚 + 𝒕𝒚
ATME COLLEGE OF ENGINEERING
2D TRANSFORMATIONS
• Scaling: Scaling changes the size of an object. In 2D, scaling can be uniform (same
scale factor for both x and y) or non-uniform (different scale factors for x and y). To
scale a point (x, y) by factors 𝑆x and 𝑆y , the new coordinates (x', y') can be calculated
ATME COLLEGE OF ENGINEERING
as:
𝑥′=𝑥⋅𝑆x
𝑦′=𝑦⋅𝑆y
• Reflection: Reflection flips an object over a line. In 2D, reflection is often
performed over the x-axis, y-axis, or a specified line. To reflect a point (x, y)
over the x-axis, the new coordinates (x', y') are (x, -y).
ATME COLLEGE OF ENGINEERING
Matrix Representation
Homogeneous coordinates allow for transformations such as translation, rotation, scaling, and
perspective projection to be represented as matrix operations, which can simplify calculations
and make transformations more efficient. They are particularly useful for representing points at
infinity, which cannot be represented in Cartesian coordinates.
Model Transformation:
• Converts vertices from model space (local object coordinates) to world space.
• Uses a model matrix to apply transformations like translation, rotation, and scaling.
View Transformation:
• Transforms vertices from world space to camera (view) space.
• Uses a view matrix that represents the camera's position and orientation.
Projection Transformation:
• Projects the vertices from view space to clip space.
• Uses a projection matrix (perspective or orthographic) to apply the perspective divide.
Rasterization:
• Converts primitives (points, lines, triangles) into fragments.
• Fragments represent potential pixels on the screen, containing interpolated vertex data such as
color, depth, and texture coordinates.
Fragment Processing:
• Processes fragments using fragment shaders.
• Applies operations like texturing, lighting, and color blending.
• Translation: glTranslate*(tx,ty,tz)
tz=0.0 for 2D
glm::mat4 model = glm::mat4(1.0f); // Identity matrix
model = glm::translate(model, glm::vec3(x, y, z)); // Translate by (x, y, z)
• Scaling: glScale(sx,sy,sz);
sx=1.0
model = glm::scale(model, glm::vec3(scaleX, scaleY, scaleZ)); // Scale by (scaleX, scaleY, scaleZ)
Three-Dimensional Translation
A position P = (x, y, z) in three-dimensional space is translated to a location P = (x` , y` , z` ) by adding
translation distances tx, ty, and tz to the Cartesian coordinates of P:
three-dimensional translation operations in matrix form and the coordinate positions, P and P`, are
represented in homogeneous coordinates with four-element column matrices, and the translation operator
T is a 4 × 4 matrix:
Parameter θ specifies the rotation angle about the z axis, and z-coordinate values are unchanged by this
transformation. In homogeneous-coordinate form, the three-dimensional z-axis rotation equations are
Where scaling parameters sx, sy, and sz are assigned any positive values. Explicit expressions for the scaling
transformation relative to the origin are