|
|
(437 intermediate revisions by more than 100 users not shown) |
Line 1: |
Line 1: |
| In [[linear algebra]], [[linear transformation]]s can be represented by [[matrix (math)|matrices]]. If ''T'' is a linear transformation mapping '''R'''<sup>''n''</sup> to '''R'''<sup>''m''</sup> and <math>\vec x</math> is a [[column vector]] with ''n'' entries, then
| | This is a preview for the new '''MathML rendering mode''' (with SVG fallback), which is availble in production for registered users. |
|
| |
|
| :<math>T( \vec x ) = \mathbf{A} \vec x</math> | | If you would like use the '''MathML''' rendering mode, you need a wikipedia user account that can be registered here [[https://en.wikipedia.org/wiki/Special:UserLogin/signup]] |
| | * Only registered users will be able to execute this rendering mode. |
| | * Note: you need not enter a email address (nor any other private information). Please do not use a password that you use elsewhere. |
|
| |
|
| for some ''m''×''n'' matrix '''A''', called the '''transformation matrix of ''T'''''.
| | Registered users will be able to choose between the following three rendering modes: |
| There is an alternative expression of transformation matrices involving [[row vector]]s that is preferred by some authors.
| |
| == Uses ==
| |
|
| |
|
| Matrices allow arbitrary [[linear transformations]] to be represented in a consistent format, suitable for computation. This also allows transformations to be concatenated easily (by multiplying their matrices).
| | '''MathML''' |
| | :<math forcemathmode="mathml">E=mc^2</math> |
|
| |
|
| Linear transformations are not the only ones that can be represented by matrices. Some transformations that are non-linear on a n-dimensional [[Euclidean space]] '''R'''<sup>''n''</sup>, can be represented as linear transformations on the ''n''+1-dimensional space '''R'''<sup>''n''+1</sup>. These include both [[affine transformations]] (such as [[Translation (geometry)|translation]]) and [[projective transformation]]s. For this reason, 4x4 transformation matrices are widely used in [[3D computer graphics]]. These ''n''+1-dimensional transformation matrices are called, depending on their application, ''affine transformation matrices'', ''projective transformation matrices'', or more generally ''non-linear transformation matrices''. With respect to an ''n''-dimensional matrix, an ''n''+1-dimensional matrix can be described as an [[augmented matrix]].
| | <!--'''PNG''' (currently default in production) |
| | :<math forcemathmode="png">E=mc^2</math> |
|
| |
|
| In the [[physics|physical sciences]], an [[active transformation]] is one which actually changes the physical position of a [[system]], and makes sense even in the absence of a [[coordinate system]] whereas a [[passive transformation]] is a change in the coordinate description of the physical system ([[change of basis]]). The distinction between active and passive [[Transformation (mathematics)|transformation]]s is important. By default, by ''transformation'', [[mathematician]]s usually mean active transformations, while [[physicist]]s could mean either.
| | '''source''' |
| | :<math forcemathmode="source">E=mc^2</math> --> |
|
| |
|
| Put differently, a ''passive'' transformation refers to observation of the ''same'' event from two different coordinate frames.
| | <span style="color: red">Follow this [https://en.wikipedia.org/wiki/Special:Preferences#mw-prefsection-rendering link] to change your Math rendering settings.</span> You can also add a [https://en.wikipedia.org/wiki/Special:Preferences#mw-prefsection-rendering-skin Custom CSS] to force the MathML/SVG rendering or select different font families. See [https://www.mediawiki.org/wiki/Extension:Math#CSS_for_the_MathML_with_SVG_fallback_mode these examples]. |
|
| |
|
| ==Finding the matrix of a transformation== | | ==Demos== |
|
| |
|
| If one has a linear transformation <math>T(x)</math> in functional form, it is easy to determine the transformation matrix '''A''' by simply transforming each of the vectors of the [[standard basis]] by ''T'' and then inserting the results into the columns of a matrix. In other words,
| | Here are some [https://commons.wikimedia.org/w/index.php?title=Special:ListFiles/Frederic.wang demos]: |
|
| |
|
| :<math>\mathbf{A} = \begin{bmatrix} T( \vec e_1 ) & T( \vec e_2 ) & \cdots & T( \vec e_n ) \end{bmatrix}</math>
| |
|
| |
|
| For example, the function <math>T(x) = 5x</math> is a linear transformation. Applying the above process (suppose that ''n'' = 2 in this case) reveals that
| | * accessibility: |
| | ** Safari + VoiceOver: [https://commons.wikimedia.org/wiki/File:VoiceOver-Mac-Safari.ogv video only], [[File:Voiceover-mathml-example-1.wav|thumb|Voiceover-mathml-example-1]], [[File:Voiceover-mathml-example-2.wav|thumb|Voiceover-mathml-example-2]], [[File:Voiceover-mathml-example-3.wav|thumb|Voiceover-mathml-example-3]], [[File:Voiceover-mathml-example-4.wav|thumb|Voiceover-mathml-example-4]], [[File:Voiceover-mathml-example-5.wav|thumb|Voiceover-mathml-example-5]], [[File:Voiceover-mathml-example-6.wav|thumb|Voiceover-mathml-example-6]], [[File:Voiceover-mathml-example-7.wav|thumb|Voiceover-mathml-example-7]] |
| | ** [https://commons.wikimedia.org/wiki/File:MathPlayer-Audio-Windows7-InternetExplorer.ogg Internet Explorer + MathPlayer (audio)] |
| | ** [https://commons.wikimedia.org/wiki/File:MathPlayer-SynchronizedHighlighting-WIndows7-InternetExplorer.png Internet Explorer + MathPlayer (synchronized highlighting)] |
| | ** [https://commons.wikimedia.org/wiki/File:MathPlayer-Braille-Windows7-InternetExplorer.png Internet Explorer + MathPlayer (braille)] |
| | ** NVDA+MathPlayer: [[File:Nvda-mathml-example-1.wav|thumb|Nvda-mathml-example-1]], [[File:Nvda-mathml-example-2.wav|thumb|Nvda-mathml-example-2]], [[File:Nvda-mathml-example-3.wav|thumb|Nvda-mathml-example-3]], [[File:Nvda-mathml-example-4.wav|thumb|Nvda-mathml-example-4]], [[File:Nvda-mathml-example-5.wav|thumb|Nvda-mathml-example-5]], [[File:Nvda-mathml-example-6.wav|thumb|Nvda-mathml-example-6]], [[File:Nvda-mathml-example-7.wav|thumb|Nvda-mathml-example-7]]. |
| | ** Orca: There is ongoing work, but no support at all at the moment [[File:Orca-mathml-example-1.wav|thumb|Orca-mathml-example-1]], [[File:Orca-mathml-example-2.wav|thumb|Orca-mathml-example-2]], [[File:Orca-mathml-example-3.wav|thumb|Orca-mathml-example-3]], [[File:Orca-mathml-example-4.wav|thumb|Orca-mathml-example-4]], [[File:Orca-mathml-example-5.wav|thumb|Orca-mathml-example-5]], [[File:Orca-mathml-example-6.wav|thumb|Orca-mathml-example-6]], [[File:Orca-mathml-example-7.wav|thumb|Orca-mathml-example-7]]. |
| | ** From our testing, ChromeVox and JAWS are not able to read the formulas generated by the MathML mode. |
|
| |
|
| :<math>T( \vec{x} ) = 5 \vec{x} = 5 \mathbf{I} \vec{x} = \begin{bmatrix} 5 && 0 \\ 0 && 5 \end{bmatrix} \vec{x}</math>
| | ==Test pages == |
|
| |
|
| ==Examples in 2D graphics==
| | To test the '''MathML''', '''PNG''', and '''source''' rendering modes, please go to one of the following test pages: |
| | *[[Displaystyle]] |
| | *[[MathAxisAlignment]] |
| | *[[Styling]] |
| | *[[Linebreaking]] |
| | *[[Unique Ids]] |
| | *[[Help:Formula]] |
|
| |
|
| Most common geometric transformations that keep the origin fixed are linear, including rotation, scaling, shearing, reflection, and orthogonal projection; if an affine transformation is not a pure translation it keeps some point fixed, and that point can be chosen as origin to make the transformation linear. In two dimensions, linear transformations can be represented using a 2×2 transformation matrix.
| | *[[Inputtypes|Inputtypes (private Wikis only)]] |
| | | *[[Url2Image|Url2Image (private Wikis only)]] |
| ===Rotation===
| | ==Bug reporting== |
| | | If you find any bugs, please report them at [https://bugzilla.wikimedia.org/enter_bug.cgi?product=MediaWiki%20extensions&component=Math&version=master&short_desc=Math-preview%20rendering%20problem Bugzilla], or write an email to math_bugs (at) ckurs (dot) de . |
| For [[coordinate rotation|rotation]] by an angle θ '''counter clockwise''' about the origin, the functional form is <math>x' = x \cos \theta - y \sin \theta</math> and <math>y' = x \sin \theta + y \cos \theta</math>. Written in matrix form, this becomes:
| |
| | |
| :<math>
| |
| \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} \cos \theta & -\sin\theta \\ \sin \theta & \cos \theta \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}
| |
| </math>
| |
| | |
| Similarly, for a rotation '''clockwise''' about the origin, the functional form is <math>x' = x \cos \theta + y \sin \theta</math> and <math>y' = - x \sin \theta + y \cos \theta</math> and the matrix form is:
| |
| | |
| :<math>
| |
| \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} \cos \theta & \sin\theta \\ -\sin \theta & \cos \theta \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}
| |
| </math>
| |
| | |
| ===Scaling===
| |
| | |
| For [[scaling (geometry)|scaling]] (that is, enlarging or shrinking), we have <math>x' = s_x \cdot x</math> and <math>y' = s_y \cdot y</math>. The matrix form is:
| |
| | |
| :<math>
| |
| \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} s_x & 0 \\ 0 & s_y \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}
| |
| </math>
| |
| When <math>\ s_x s_y = 1</math>, then the matrix is a [[squeeze mapping]] and preserves [[area]]s in the plane.
| |
| | |
| ===Shearing===
| |
| | |
| For [[shear mapping]] (visually similar to slanting), there are two possibilities.
| |
| | |
| A shear parallel to the ''x'' axis has <math>x' = x + ky</math> and <math>y' = y</math>. Written in matrix form, this becomes:
| |
| :<math>
| |
| \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} 1 & k \\ 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}
| |
| </math>
| |
| | |
| A shear parallel to the ''y'' axis has <math>x' = x</math> and <math>y' = y + kx</math>, which has matrix form:
| |
| :<math>
| |
| \begin{bmatrix} x' \\ y' \end{bmatrix} = \begin{bmatrix} 1 & 0 \\ k & 1 \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix}
| |
| </math>
| |
| | |
| ===Reflection ===
| |
| | |
| To reflect a vector about a line that goes through the origin, let <math>\scriptstyle \vec{l} = (l_x, l_y)</math> be a [[vector (geometric)|vector]] in the direction of the line:
| |
| | |
| :<math>
| |
| \mathbf{A} = \frac{1}{\lVert\vec{l}\rVert^2} \begin{bmatrix} l_x^2 - l_y^2 & 2 l_x l_y \\ 2 l_x l_y & l_y^2 - l_x^2 \end{bmatrix}
| |
| </math>
| |
| | |
| To reflect a point through a plane <math>ax + by + cz = 0</math> (which goes through the origin), one can use <math>\mathbf{A} = \mathbf{I}-2\mathbf{NN}^T </math>, where <math>\mathbf{I}</math> is the 3x3 identity matrix and <math>\mathbf{N}</math> is the three-dimensional [[unit vector]] for the surface normal of the plane. If the [[L2 norm]] of <math>a, b,</math> and <math>c</math> is unity, the transformation matrix can be expressed as:
| |
| | |
| <math>
| |
| \mathbf{A} = \begin{bmatrix} 1 - 2 a^2 & - 2 a b & - 2 a c \\ - 2 a b & 1 - 2 b^2 & - 2 b c \\ - 2 a c & - 2 b c & 1 - 2c^2 \end{bmatrix}
| |
| </math>
| |
| | |
| Note that these are particular cases of a [[Householder reflection]] in two and three dimensions. A reflection about a line or plane that does not go through the origin is not a linear transformation; it is an [[affine transformation]].
| |
| | |
| ===Orthogonal projection=== | |
| | |
| To project a vector orthogonally onto a line that goes through the origin, let <math>\scriptstyle \vec{u} \,=\, (u_x, u_y)</math> be a [[vector (geometric)|vector]] in the direction of the line. Then use the transformation matrix:
| |
| | |
| :<math>
| |
| \mathbf{A} = \frac{1}{\lVert\vec{u}\rVert^2} \begin{bmatrix} u_x^2 & u_x u_y \\ u_x u_y & u_y^2 \end{bmatrix}
| |
| </math>
| |
| | |
| As with reflections, the orthogonal projection onto a line that does not pass through the origin is an affine, not linear, transformation.
| |
| | |
| [[Projection (linear algebra)|Parallel projection]]s are also linear transformations and can be represented simply by a matrix. However, perspective projections are not, and to represent these with a matrix, [[Homogeneous_coordinates#Use_in_computer_graphics|homogeneous coordinates]] must be used.
| |
| | |
| ==Composing and inverting transformations==
| |
| | |
| One of the main motivations for using matrices to represent linear transformations is that transformations can then be easily composed (combined) and inverted.
| |
| | |
| Composition is accomplished by [[matrix multiplication]]. If '''A''' and '''B''' are the matrices of two linear transformations, then the effect of applying first '''A''' and then '''B''' to a vector ''x'' is given by:
| |
| | |
| :<math>\mathbf{B}(\mathbf{A} \vec{x} ) = (\mathbf{BA}) \vec{x}</math>
| |
| | |
| (This is called the [[Associative property]].)
| |
| In other words, the matrix of the combined transformation '''''A''' followed by '''B''''' is simply the product of the individual matrices. Note that the multiplication is done in the opposite order from the English sentence: the matrix of "'''A''' followed by '''B'''" is '''BA''', not '''AB'''.
| |
| | |
| A consequence of the ability to compose transformations by multiplying their matrices is that transformations can also be inverted by simply [[Invertible matrix|inverting their matrices]]. So, '''A'''<sup>-1</sup> represents the transformation that "undoes" '''A'''.
| |
| | |
| ==Other kinds of transformations== | |
| | |
| ===Affine transformations===<!-- This section is linked from [[Affine transformation]] -->
| |
| 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</math>; <math>y' = y + t_y</math> becomes:
| |
| | |
| :<math>
| |
| \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 be also 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 '''anti-clockwise''' rotation matrix from above'' becomes:
| |
| | |
| :<math>\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 can be seamlessly intermixed with all other types of transformations. The reason is that the real plane is mapped to the ''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 transformation in a 2-D or 3-D Euclidean space described by Cartesian coordinates, it becomes, in a 3-D or 4-D projective space described by homogeneous coordinates, a simple linear transformation (a shear).
| |
| | |
| 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===
| |
| {{see also|3D projection#Perspective projection}}
| |
| 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.
| |
| | |
| The simplest perspective projection uses the origin as the center of projection, and ''z'' = 1 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>
| |
| \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 ''w<sub>c</sub>'' will, in general, not be equal to 1. Therefore, to map back into the real plane we must perform the '''homogeneous divide''' or '''perspective divide''' by dividing each component by ''w<sub>c</sub>'':
| |
| | |
| :<math>
| |
| \begin{bmatrix} x' \\ y' \\ z' \end{bmatrix} = \frac{1}{w_c} \begin{bmatrix} x_c \\ y_c \\ z_c \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.
| |
| | |
| ==See also==
| |
| * [[3D projection]]
| |
| * [[Transformation (geometry)]]
| |
| * [[Translation matrix]]
| |
| * [[Rotation matrix]]
| |
| * [[Scaling (geometry)]]
| |
| | |
| ==External links==
| |
| * [http://web.archive.org/web/20091027131421/http://geocities.com/evilsnack/matrix.htm The Matrix Page] Practical examples in [[POV-Ray]]
| |
| * [http://mathworld.wolfram.com/RotationMatrix.html Reference page] - Rotation of axes
| |
| * [http://www.idomaths.com/linear_transformation.php Linear Transformation Calculator]
| |
| * [http://www.wiley.com/legacy/products/subject/life/biological_anthropology/0471205079_virtual_reconstruction/chapter5_trafo.html Transformation Applet] - Generate matrices from 2D transformations and vice versa.
| |
| | |
| [[Category:Computer graphics]]
| |
| [[Category:Transformation (function)]]
| |
| [[Category:Matrices]]
| |
| | |
| {{Unreferenced|date=December 2007}}
| |
| | |
| [[de:Abbildungsmatrix]]
| |
| [[fr:Matrice de passage]]
| |
| [[it:Matrice di trasformazione]]
| |
| [[he:מטריצת מעבר]]
| |
| [[no:Transformasjonsmatrise]]
| |
| [[pl:Macierz przekształcenia liniowego]]
| |
| [[ru:Матрица перехода]]
| |
| [[sl:Matrika preslikave]]
| |
| [[uk:Матриця переходу]]
| |
| [[vi:Ma trận của biến đổi tuyến tính]]
| |
| [[zh:变换矩阵]]
| |