## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

**An matrix is a set oI numbers arranged in rows and columns. The Iollowing
**

illustration shows several matrices.

Illustration showing six matrices of varying dimensions

You can add two matrices oI the same size by adding individual elements. The Iollowing

illustration shows two examples oI matrix addition.

Illustration that shows how to perform matrix addition

An matrix can be multiplied by an matrix. and the result is an matrix. The

number oI columns in the Iirst matrix must be the same as the number oI rows in the

second matrix. For example. a 4 ×2 matrix can be multiplied by a 2 ×3 matrix to produce

a 4 ×3 matrix.

Points in the plane and rows and columns oI a matrix can be thought oI as vectors. For

example. (2. 5) is a vector with two components. and (3. 7. 1) is a vector with three

components. The dot product oI two vectors is deIined as Iollows:

(a. b) (c. d) ÷ ac ¹ bd

(a. b. c) (d. e. I) ÷ ad ¹ be ¹ cI

For example. the dot product oI (2. 3) and (5. 4) is (2)(5) ¹ (3)(4) ÷ 22. The dot product

oI (2. 5. 1) and (4. 3. 1) is (2)(4) ¹ (5)(3) ¹ (1)(1) ÷ 24. Note that the dot product oI two

vectors is a number. not another vector. Also note that you can calculate the dot product

only iI the two vectors have the same number oI components.

Let A(i. i) be the entry in matrix A in the ith row and the ith column. For example A(3.

2) is the entry in matrix A in the 3rd row and the 2nd column. Suppose A. B. and C are

matrices. and AB ÷ C. The entries oI C are calculated as Iollows:

C(i. i) ÷ (row i oI A) (column i oI B)

The Iollowing illustration shows several examples oI matrix multiplication.

Illustration that shows how to perform matrix multiplication

II you think oI a point in the plane as a 1 × 2 matrix. you can transIorm that point by

multiplying it by a 2 × 2 matrix. The Iollowing illustration shows several transIormations

applied to the point (2. 1).

Illustration that shows how to use matrix multiplication to scale. rotate. or reflect a

point in a plane

All the transIormations shown in the previous Iigure are linear transIormations. Certain

other transIormations. such as translation. are not linear. and cannot be expressed as

multiplication by a 2 × 2 matrix. Suppose you want to start with the point (2. 1). rotate it

90 degrees. translate it 3 units in the x direction. and translate it 4 units in the y direction.

You can accomplish this by perIorming a matrix multiplication Iollowed by a matrix

addition.

Illustration that shows how matrix multiplication and addition can rotate a point

and translate it twice

A linear transIormation (multiplication by a 2 × 2 matrix) Iollowed by a translation

(addition oI a 1 × 2 matrix) is called an aIIine transIormation. An alternative to storing an

aIIine transIormation in a pair oI matrices (one Ior the linear part and one Ior the

translation) is to store the entire transIormation in a 3 × 3 matrix. To make this work. a

point in the plane must be stored in a 1 × 3 matrix with a dummy 3rd coordinate. The

usual technique is to make all 3rd coordinates equal to 1. For example. the point (2. 1) is

represented by the matrix |2 1 1|. The Iollowing illustration shows an aIIine

transIormation (rotate 90 degrees; translate 3 units in the x direction. 4 units in the y

direction) expressed as multiplication by a single 3 × 3 matrix.

Illustration that shows how matrix multiplication can perform an affine

transformation

In the previous example. the point (2. 1) is mapped to the point (2. 6). Note that the third

column oI the 3 × 3 matrix contains the numbers 0. 0. 1. This will always be the case Ior

the 3 × 3 matrix oI an aIIine transIormation. The important numbers are the six numbers

in columns 1 and 2. The upper-leIt 2 × 2 portion oI the matrix represents the linear part oI

the transIormation. and the Iirst two entries in the 3rd row represent the translation.

Illustration showing that the first two columns are most significant for a 3x3 matrix

of an affine transformation

In Windows GDI¹ you can store an aIIine transIormation in a Matrix obiect. Because

the third column oI a matrix that represents an aIIine transIormation is always (0. 0. 1).

you speciIy only the six numbers in the Iirst two columns when you construct a Matrix

obiect. The statement Matrix myMatrix(0.0f, 1.0f, -1.0f, 0.0f, 3.0f, 4.0f);

constructs the matrix shown in the previous Iigure.

Composite Transformations

A composite transIormation is a sequence oI transIormations. one Iollowed by the other.

Consider the matrices and transIormations in the Iollowing list:

• Matrix A Rotate 90 degrees

• Matrix B Scale by a Iactor oI 2 in the x direction

• Matrix C Translate 3 units in the y direction

II you start with the point (2. 1) represented by the matrix |2 1 1| and multiply by

A. then B. then C. the point (2.1) will undergo the three transIormations in the order

listed.

|2 1 1|ABC ÷ | 2 5 1|

Rather than store the three parts oI the composite transIormation in three separate

matrices. you can multiply A. B. and C together to get a single 3 × 3 matrix that stores

the entire composite transIormation. Suppose ABC ÷ D. Then a point multiplied by D

gives the same result as a point multiplied by A. then B. then C.

|2 1 1|D ÷ | 2 5 1|

The Iollowing illustration shows the matrices A. B. C. and D.

Illustration showing how to perform multiple transformations by multiplying the

constituent matrices

The Iact that the matrix oI a composite transIormation can be Iormed by multiplying the

individual transIormation matrices means that any sequence oI aIIine transIormations can

be stored in a single Matrix obiect.

Note The order oI a composite transIormation is important. In general. rotate. then

scale. then translate is not the same as scale. then rotate. then translate. Similarly. the

order oI matrix multiplication is important. In general. ABC is not the same as BAC.

The Matrix class provides several methods Ior building a composite transIormation:

Matrix::Multiply. Matrix::Rotate. Matrix::RotateAt. Matrix::Scale. Matrix::Shear.

and Matrix::Translate. The Iollowing example creates the matrix oI a composite

transIormation that Iirst rotates 30 degrees. then scales by a Iactor oI 2 in the y direction.

and then translates 5 units in the x direction.

Copy

Matrix myMatrix;

myMatrix.Rotate(30.0f);

myMatrix.Scale(1.0f, 2.0f, MatrixOrderAppend);

myMatrix.Translate(5.0f, 0.0f, MatrixOrderAppend);

The Iollowing illustration shows the matrix.

Illustration that shows a matrix with values expressed as trigonometric functions.

and a matrix with approximate values of those functions

!& $ /& " 1+2 2 / 1& ! / 0 ) 1 2 $" 2$ /& + $ &*$ 3 4 ! ! $! (& ( ! ..

& - .2 ! 56 ! " 0 $! (& $ $ & ( 7 $ & 4 56 " 8! ( (9 : " " ( ! & $ ! ! & " 7 " " ( 4 4 $! (& " " 3 " " " ( ! < " $! (& 6 6 ( ! ! " $! .

3 = >?3. / 1 $6 6 (& / 7 2 • • • ) @ @ @ A 1 0 2 56 ! " $! (& B $! (& 8! ( (9 B 3 1 2 8! ( (9 12 + 8 C! % (9 A 1 2 0 " 12 + ? 1 2 " ? 8! ( (9? + 8 C! % (9 1 2 ? .

7 / 3 0 3 12 1 2 ) ! "6 % 2 " ! " ! " # .

- The Unwinding
- Yes Please
- Sapiens
- Dispatches from Pluto
- Elon Musk
- The Innovators
- Devil in the Grove
- John Adams
- The Emperor of All Maladies
- A Heartbreaking Work Of Staggering Genius
- This Changes Everything
- Grand Pursuit
- The Prize
- The New Confessions of an Economic Hit Man
- Team of Rivals
- The World Is Flat 3.0
- Smart People Should Build Things
- The Hard Thing About Hard Things
- Rise of ISIS
- Steve Jobs
- Angela's Ashes
- How To Win Friends and Influence People
- Bad Feminist

- The Light Between Oceans
- Extremely Loud and Incredibly Close
- The Sympathizer
- The Silver Linings Playbook
- Leaving Berlin
- You Too Can Have a Body Like Mine
- The Incarnations
- The Love Affairs of Nathaniel P.
- Life of Pi
- Bel Canto
- The Master
- A Man Called Ove
- The Flamethrowers
- Brooklyn
- The Blazing World
- The Rosie Project
- The First Bad Man
- We Are Not Ourselves
- The Wallcreeper
- The Art of Racing in the Rain
- Wolf Hall
- Beautiful Ruins
- The Kitchen House
- Interpreter of Maladies
- The Perks of Being a Wallflower
- Lovers at the Chameleon Club, Paris 1932
- The Bonfire of the Vanities
- The Cider House Rules
- A Prayer for Owen Meany
- Mislaid

Close Dialog## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

Loading