Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Transformation matrix
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Other kinds of transformations== ===Affine transformations=== <!-- This section is linked from [[Affine transformation]] --> [[File:2D affine transformation matrix.svg|thumb|250px|right|Effect of applying various 2D affine transformation matrices on a unit square. Note that the reflection matrices are special cases of the scaling matrix.]] [[File:Affine transformations.ogv|thumb|250px|right|Affine transformations on the 2D plane can be performed in three dimensions. Translation is done by shearing parallel to the xy plane, and rotation is performed around the z axis.]] To represent [[affine transformation]]s with matrices, we can use [[homogeneous coordinates]]. This means representing a 2-vector (''x'', ''y'') as a 3-vector (''x'', ''y'', 1), and similarly for higher dimensions. Using this system, translation can be expressed with matrix multiplication. The functional form <math>x' = x + t_x; y' = y + t_y</math> becomes: <math display="block">\begin{bmatrix} x' \\ y' \\ 1 \end{bmatrix} = \begin{bmatrix} 1 & 0 & t_x \\ 0 & 1 & t_y \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \\ 1 \end{bmatrix}.</math> All ordinary linear transformations are included in the set of affine transformations, and can be described as a simplified form of affine transformations. Therefore, any linear transformation can also be represented by a general transformation matrix. The latter is obtained by expanding the corresponding linear transformation matrix by one row and column, filling the extra space with zeros except for the lower-right corner, which must be set to 1. For example, ''the '''counter-clockwise''' [[rotation matrix]] from above'' becomes: <math display="block">\begin{bmatrix} \cos \theta & -\sin \theta & 0 \\ \sin \theta & \cos \theta & 0 \\ 0 & 0 & 1 \end{bmatrix}</math> Using transformation matrices containing homogeneous coordinates, translations become linear, and thus can be seamlessly intermixed with all other types of transformations. The reason is that the real plane is mapped to the {{math|1=''w'' = 1}} plane in real projective space, and so translation in real [[Euclidean space]] can be represented as a shear in real projective space. Although a translation is a non-[[Linear map|linear transformation]] in a 2-D or 3-D Euclidean space described by Cartesian coordinates (i.e. it can't be combined with other transformations while preserving [[Commutative property|commutativity]] and other properties), it [[Translation (geometry)#Matrix representation|becomes]], in a 3-D or 4-D projective space described by homogeneous coordinates, a simple linear transformation (a [[Shear mapping|shear]]). More affine transformations can be obtained by [[Linear combination|composition]] of two or more affine transformations. For example, given a translation '''T'''' with vector <math>(t'_x, t'_y),</math> a rotation '''R''' by an angle θ '''counter-clockwise''', a scaling '''S''' with factors <math>(s_x, s_y)</math> and a translation '''T''' of vector <math>(t_x, t_y),</math> the result '''M''' of '''T'RST''' is:<ref>{{cite web |url = http://totologic.blogspot.com/2015/02/2d-transformation-matrices-baking.html |title = 2D transformation matrices baking |author = Cédric Jules |date = February 25, 2015 }}</ref> <math display="block">\begin{bmatrix} s_x \cos \theta & - s_y \sin \theta & t_x s_x \cos \theta - t_y s_y \sin \theta + t'_x \\ s_x \sin \theta & s_y \cos \theta & t_x s_x \sin \theta + t_y s_y \cos \theta + t'_y \\ 0 & 0 & 1 \end{bmatrix}</math> When using affine transformations, the homogeneous component of a coordinate vector (normally called ''w'') will never be altered. One can therefore safely assume that it is always 1 and ignore it. However, this is not true when using perspective projections. ===Perspective projection=== {{main|Perspective projection}} {{further|Pinhole camera model}} [[File:Perspective transformation matrix 2D.svg|thumb|Comparison of the effects of applying 2D affine and perspective transformation matrices on a unit square.]] Another type of transformation, of importance in [[3D computer graphics]], is the [[perspective projection]]. Whereas parallel projections are used to project points onto the image plane along parallel lines, the perspective projection projects points onto the image plane along lines that emanate from a single point, called the center of projection. This means that an object has a smaller projection when it is far away from the center of projection and a larger projection when it is closer (see also [[Multiplicative inverse|reciprocal function]]). The simplest perspective projection uses the origin as the center of projection, and the plane at <math>z = 1</math> as the image plane. The functional form of this transformation is then <math>x' = x / z</math>; <math>y' = y / z</math>. We can express this in [[homogeneous coordinates]] as: <math display="block">\begin{bmatrix} x_c \\ y_c \\ z_c \\ w_c \end{bmatrix} = \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 1 & 0 \end{bmatrix} \begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix}=\begin{bmatrix} x \\ y \\ z \\ z \end{bmatrix} </math> After carrying out the [[matrix multiplication]], the homogeneous component <math>w_c</math> will be equal to the value of <math>z</math> and the other three will not change. Therefore, to map back into the real plane we must perform the '''homogeneous divide''' or '''perspective divide''' by dividing each component by <math>w_c</math>: <math display="block">\begin{bmatrix} x' \\ y' \\ z' \\ 1 \end{bmatrix} = \frac{1}{w_c} \begin{bmatrix} x_c \\ y_c \\ z_c \\ w_c \end{bmatrix}=\begin{bmatrix} x / z \\ y / z \\ 1 \\ 1 \end{bmatrix}</math> More complicated perspective projections can be composed by combining this one with rotations, scales, translations, and shears to move the image plane and center of projection wherever they are desired.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)