Download Examples in 2D graphics

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Linear least squares (mathematics) wikipedia , lookup

Covariance and contravariance of vectors wikipedia , lookup

Jordan normal form wikipedia , lookup

Determinant wikipedia , lookup

System of linear equations wikipedia , lookup

Principal component analysis wikipedia , lookup

Rotation matrix wikipedia , lookup

Singular-value decomposition wikipedia , lookup

Non-negative matrix factorization wikipedia , lookup

Eigenvalues and eigenvectors wikipedia , lookup

Matrix (mathematics) wikipedia , lookup

Gaussian elimination wikipedia , lookup

Perron–Frobenius theorem wikipedia , lookup

Cayley–Hamilton theorem wikipedia , lookup

Matrix calculus wikipedia , lookup

Four-vector wikipedia , lookup

Orthogonal matrix wikipedia , lookup

Matrix multiplication wikipedia , lookup

Transcript
Examples in 2D graphics
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.
Rotation
For rotation by an angle θ counterclockwise about the origin, the functional form is x'
= xcosθ − ysinθ and y' = xsinθ + ycosθ. Written in matrix form, this becomes:
Scaling
For scaling (that is, enlarging or shrinking), we have
The matrix form is:
and
.
Shearing
For shearing (visually similar to slanting), there are two possibilities. A shear parallel
to the x axis has x' = x + ky and y' = y; the matrix form is:
A shear parallel to the y axis has x' = x and y' = y + kx, which has matrix form:
Reflection
To reflect a vector about a line that goes through the origin, let (ux, uy) be a unit vector
in the direction of the line. Then use the transformation matrix:
A reflection about a line 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 (ux, uy) be
a unit vector in the direction of the line. Then use the transformation matrix:
As with reflections, the orthogonal projection onto a line that does not pass through
the origin is an affine, not linear, transformation.
Parallel projections 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 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:
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 inverting their
matrices. So, A-1 represents the transformation that "undoes" A.
Transformation matrices are not always invertible, but often there is an intuitive
explanation. In the previous section, almost all transformations are invertible. The
scaling transformation is invertible as long as neither sx nor sy are zero (this is easily
understood as we "destroy" information by simply discarding one dimension if any of
the two coefficients are zero). Also, orthogonal projection is never invertible. (In the
material for Wednesday and Thursday Week 2 we shall see that this is a general
property of projections.)