Difference between revisions of "ApplyMatrix Command"

From GeoGebra Manual
Jump to: navigation, search
m (Text replace - "<div class="box info"> 48px|left This page is part of the official manual for print and pdf. For structural reasons normal users can't edit this page. If you found any errors on this page please contact )
 
(15 intermediate revisions by 6 users not shown)
Line 1: Line 1:
<noinclude>{{Manual Page|version=4.2}}</noinclude>
+
<noinclude>{{Manual Page|version=5.0}}</noinclude>{{command|vector-matrix}}
{{command|vector-matrix}}
+
; ApplyMatrix( <[[Matrices|Matrix]]>, <[[Geometric Objects|Object]]> ): Transforms the object ''O'' so that point ''P'' of ''O'' is mapped to:
; ApplyMatrix[ <[[Matrices|Matrix]] M>, <[[Geometric Objects|Geometric Object]] O>]: Transforms the object so that point ''P'' of ''O'' is mapped to  
+
* point ''M*P'', if ''P'' is a ''2D'' point and ''M'' is a 2 x 2 matrix
* point ''M*P'' in case M is a 2x2 matrix or
+
:{{example|1= Let <code>M={{cos(π/2),-sin(π/2)}, {sin(π/2), cos(π/2)}}</code> be the transformation matrix and <code>u = (2,1)</code> a given vector (object). <code>ApplyMatrix(M,u)</code> yields the vector ''u'=(-1,2)'', i.e. the result of a mathematically positive rotation by 90° of vector ''u''.}}
* point ''project(M*(x(P), y(P), 1))'' where ''project'' is a projection mapping point ''(x,y,z)'' to ''(x/z, y/z)'' in case of 3x3 matrix.  
+
* point ''project(M*(x(P), y(P), 1))'', if ''P'' is a ''2D'' point and ''M'' a 3 x 3 matrix: ''project'' is a projection, mapping point ''(x, y, z)'' to ''(x/z, y/z)''.
; ApplyMatrix[ <Matrix M>, <[[Images|Image]] I>]: Applies the same transformation as above to image I.
+
:{{example|1=Let <code>M={{1,1,0},{0,1,1},{1,0,1}}</code> be a matrix and <code>u=(2,1)</code> a given vector. <code>ApplyMatrix(M,u)</code> yields vector ''u'=(1,0.67)''. In effect <math>\begin{pmatrix}1&1&0\\ 0&1&1\\1&0&1 \end{pmatrix}</math> <math>\begin{pmatrix}2\\ 1\\1 \end{pmatrix}</math> =  <math>\begin{pmatrix}3\\ 2\\3 \end{pmatrix}</math>, and (3/3 = 1, 2/3 ≈ 0.67) (rounding to 2 decimal places)}}
 +
* point ''M*P'', if ''P'' is a ''3D'' point and ''M'' a 3 x 3 matrix
 +
* point ''N*P'', if  ''P'' is a ''3D'' point and ''M'' a 2 x 2 matrix: the matrix ''N'' is the ''completion or order 3'' of ''M'': given ''M'' = <math>\begin{pmatrix}a&b\\ c&d \end{pmatrix}</math> then ''N'' = <math>\begin{pmatrix}a&b&0\\ c&d&0\\0&0&1 \end{pmatrix}</math>
 +
:{{note| 1=This command also works with quadrics and [[Images|images]]: it will return "undefined" when the determinant of the transformation matrix is 0.}}

Latest revision as of 14:52, 19 June 2023


ApplyMatrix( <Matrix>, <Object> )
Transforms the object O so that point P of O is mapped to:
  • point M*P, if P is a 2D point and M is a 2 x 2 matrix
Example: Let M={{cos(π/2),-sin(π/2)}, {sin(π/2), cos(π/2)}} be the transformation matrix and u = (2,1) a given vector (object). ApplyMatrix(M,u) yields the vector u'=(-1,2), i.e. the result of a mathematically positive rotation by 90° of vector u.
  • point project(M*(x(P), y(P), 1)), if P is a 2D point and M a 3 x 3 matrix: project is a projection, mapping point (x, y, z) to (x/z, y/z).
Example: Let M={{1,1,0},{0,1,1},{1,0,1}} be a matrix and u=(2,1) a given vector. ApplyMatrix(M,u) yields vector u'=(1,0.67). In effect \begin{pmatrix}1&1&0\\ 0&1&1\\1&0&1 \end{pmatrix} \begin{pmatrix}2\\ 1\\1 \end{pmatrix} = \begin{pmatrix}3\\ 2\\3 \end{pmatrix}, and (3/3 = 1, 2/3 ≈ 0.67) (rounding to 2 decimal places)
  • point M*P, if P is a 3D point and M a 3 x 3 matrix
  • point N*P, if P is a 3D point and M a 2 x 2 matrix: the matrix N is the completion or order 3 of M: given M = \begin{pmatrix}a&b\\ c&d \end{pmatrix} then N = \begin{pmatrix}a&b&0\\ c&d&0\\0&0&1 \end{pmatrix}
Note: This command also works with quadrics and images: it will return "undefined" when the determinant of the transformation matrix is 0.
© 2024 International GeoGebra Institute