English 中文(简体)
3D Transformation
  • 时间:2024-12-22

3D Transformation


Previous Page Next Page  

Rotation

3D rotation is not same as 2D rotation. In 3D rotation, we have to specify the angle of rotation along with the axis of rotation. We can perform 3D rotation about X, Y, and Z axes. They are represented in the matrix form as below −

$$R_{x}( heta) = egin{bmatrix} 1& 0& 0& 0\ 0& cos heta & −sin heta& 0\ 0& sin heta & cos heta& 0\ 0& 0& 0& 1\ end{bmatrix} R_{y}( heta) = egin{bmatrix} cos heta& 0& sin heta& 0\ 0& 1& 0& 0\ −sin heta& 0& cos heta& 0\ 0& 0& 0& 1\ end{bmatrix} R_{z}( heta) =egin{bmatrix} cos heta & −sin heta & 0& 0\ sin heta & cos heta & 0& 0\ 0& 0& 1& 0\ 0& 0& 0& 1 end{bmatrix}$$

The following figure explains the rotation about various axes −

Rotation 3D Rotation

Scapng

You can change the size of an object using scapng transformation. In the scapng process, you either expand or compress the dimensions of the object. Scapng can be achieved by multiplying the original coordinates of the object with the scapng factor to get the desired result. The following figure shows the effect of 3D scapng −

3D Scapng

In 3D scapng operation, three coordinates are used. Let us assume that the original coordinates are (X, Y, Z), scapng factors are $(S_{X,} S_{Y,} S_{z})$ respectively, and the produced coordinates are (X’, Y’, Z’). This can be mathematically represented as shown below −

$S = egin{bmatrix} S_{x}& 0& 0& 0\ 0& S_{y}& 0& 0\ 0& 0& S_{z}& 0\ 0& 0& 0& 1 end{bmatrix}$

P’ = P∙S

$[{X} ::: {Y} ::: {Z} ::: 1] = [X :::Y ::: Z ::: 1] :: egin{bmatrix} S_{x}& 0& 0& 0\ 0& S_{y}& 0& 0\ 0& 0& S_{z}& 0\ 0& 0& 0& 1 end{bmatrix}$

$ = [X.S_{x} ::: Y.S_{y} ::: Z.S_{z} ::: 1]$

Shear

A transformation that slants the shape of an object is called the shear transformation. Like in 2D shear, we can shear an object along the X-axis, Y-axis, or Z-axis in 3D.

Shear

As shown in the above figure, there is a coordinate P. You can shear it to get a new coordinate P , which can be represented in 3D matrix form as below −

$Sh = egin{bmatrix} 1 & sh_{x}^{y} & sh_{x}^{z} & 0 \ sh_{y}^{x} & 1 & sh_{y}^{z} & 0 \ sh_{z}^{x} & sh_{z}^{y} & 1 & 0 \ 0 & 0 & 0 & 1 end{bmatrix}$

P’ = P ∙ Sh

$X’ = X + Sh_{x}^{y} Y + Sh_{x}^{z} Z$

$Y = Sh_{y}^{x}X + Y +sh_{y}^{z}Z$

$Z = Sh_{z}^{x}X + Sh_{z}^{y}Y + Z$

Transformation Matrices

Transformation matrix is a basic tool for transformation. A matrix with n x m dimensions is multipped with the coordinate of objects. Usually 3 x 3 or 4 x 4 matrices are used for transformation. For example, consider the following matrix for various operation.

$T = egin{bmatrix} 1& 0& 0& 0\ 0& 1& 0& 0\ 0& 0& 1& 0\ t_{x}& t_{y}& t_{z}& 1\ end{bmatrix}$ $S = egin{bmatrix} S_{x}& 0& 0& 0\ 0& S_{y}& 0& 0\ 0& 0& S_{z}& 0\ 0& 0& 0& 1 end{bmatrix}$ $Sh = egin{bmatrix} 1& sh_{x}^{y}& sh_{x}^{z}& 0\ sh_{y}^{x}& 1 & sh_{y}^{z}& 0\ sh_{z}^{x}& sh_{z}^{y}& 1& 0\ 0& 0& 0& 1 end{bmatrix}$
Translation Matrix Scapng Matrix Shear Matrix
$R_{x}( heta) = egin{bmatrix} 1& 0& 0& 0\ 0& cos heta & -sin heta& 0\ 0& sin heta & cos heta& 0\ 0& 0& 0& 1\ end{bmatrix}$ $R_{y}( heta) = egin{bmatrix} cos heta& 0& sin heta& 0\ 0& 1& 0& 0\ -sin heta& 0& cos heta& 0\ 0& 0& 0& 1\ end{bmatrix}$ $R_{z}( heta) = egin{bmatrix} cos heta & -sin heta & 0& 0\ sin heta & cos heta & 0& 0\ 0& 0& 1& 0\ 0& 0& 0& 1 end{bmatrix}$
Rotation Matrix
Advertisements