# CG01：Model Transformation In Computer Graphics

This is a summary blog around "GAMES101: Introduction to Modern Computer Graphics", taught by Lingqi Yan. The knowledge and images involved are quoted from the instructor Lingqi Yan's lecture notes and book "Fundamentals of Computer Graphics 4th".

### Catalog

Why Transfromation ?

What are Transformation marices ?

1. 2D Linear transformations

1.1 Scale

1.2 Reflection

1.3 Shear

1.4 Rotation

2. Homogenous Coordinates

2.1 Why Homogenous Coordinates ?

2.2 Solution: Homogenous Coordinates !

2.3 Affine Transformations

2.4 2D Transformations in Homogenous Coordinates

3. Inverse Transform

4. Composing and Decomposing Transforms

5. 3D Transformations

5.1 Basic 3D Transformations

5.2 3D Rotations

Reference

# Why Transfromation ?

• We need to characterize the movement of the model •  We need to characterize views and projections in different dimensions and from different angles # What are Transformation marices ?

From a mathematical point of view, we can represent the transformations as marices. The importance of transformation marices in graphics needs no introduction. The scaling, rotation, and displacement of all objects can be obtained by transformation marices. There are also many applications in projection transformations, and this article will introduce some brief transformation matrices.

# 1. 2D Linear transformations

We define the simple matrix(of the same dimension) multiplication shown below as a linear transformation of the vector .

## 1.1 Scale

The scaling transformation is a transformation that acts along the coordinate axes and is defined as follows, ## 1.2 Reflection

Reflection transformation with a certain coordinate axis as the symmetry axis is defined as follows, ## 1.3 Shear

The shear causes a distortion in the image, which is produced in only one direction, i.e., the horizontal shear transformation and the vertical shear transformation, respectively. Horizontal shear transformation is defined as follows, ## 1.4 Rotation

Rotation is another very important transformation matrix. We start with the rotation matrix around the origin. In the figure below, we want to represent the rotation of the vector  to the vector  with a transformation matrix. Given that the angle between vector and the -axis is , then the length of vector is , and the coordinate can be calculated as follows,

Since the vector  is obtained by rotating the vector , its length is also , and the angle between the vector and the -axis is . It can be obtained using triangle conversion,

Known that  and , the vector  can be rewritten as,

The rotational transformation is defined as follows, # 2. Homogenous Coordinates

## 2.1 Why Homogenous Coordinates ?

When it comes to translation transformation... • Translation cannot be represented in matrix form.
• But we don’t want translation to be a special case. Is there a unified way to represent all transformations? (and what’s the cost?)

## 2.2 Solution: Homogenous Coordinates !

In order to define the translation transformations as transformation matrices, we add a third coordinate (w-coordinate),

2D point    =

2D vector  =

Matrix representation of translations,

Valid operation if w-coordinate of result is 1 or 0

In homogeneous coordinates,  is the 2D point .

## 2.3 Affine Transformations

Affine map = linear map + translation

Using homogenous coordinates, it can be defined as follows,

Note: "Affine map = linear map + translation" means it perform linear transformation first and then translation transformation

## 2.4 2D Transformations in Homogenous Coordinates

• Scale

• Rotation by angle α around the origin

• Translation

# 3. Inverse Transform

is the inverse of  transform in both a matrix and geometric sense The transformation matrix of the rotation is an orthogonal matrix, so the inverse matrix can be obtained by transposing. In other words, we can transpose a rotation transformation matrix to get its inverse transformation matrix.

# 4. Composing and Decomposing Transforms

A sequence of affine transforms can be composed to one transformation matrix by matrix multiplication. Note that matrices are applied right to left. A complex transformation can also be split into multiple simple transformations. For example, when we need to rotate around a given point c, # 5. 3D Transformations

Use homogeneous coordinates again,

3D point    =

3D vector  =

Use 4×4 matrices for affine transformations,

## 5.1 Basic 3D Transformations

• Scale

• Translation

• Rotation by angle α around x-, y-, or z-axis

• Rotation by angle α around n-axis (Rodrigues’ Rotation Formula)

## 5.2 3D Rotations

Compose any 3D rotation from x-, y-, or z-axis # Reference

 Marschner S , Shirley P. Fundamentals of Computer Graphics 4th

 Lingqi Yan,  GAMES101: 现代计算机图形学入门