Magnitude of a Vector The magnitude of a vector, denoted as |a|, is defined as the square root of...

Post on 03-Jan-2016

226 views 0 download

Tags:

Transcript of Magnitude of a Vector The magnitude of a vector, denoted as |a|, is defined as the square root of...

Magnitude Magnitude of a Vectorof a Vector• The magnitude of a vector, denoted as |a|, is defined

as the square root of the sum of the squares of its components:

|a| = (x2 + y2) ½ .if a = (1, 2), its magnitude |a| = (1+4) ½ = 5 ½ .

• The distance between any two points p(x1,y1) and q(x2,y2) in a plane is equal to the magnitude of a vector connecting p and q.

|p-q| = [(x1-x2)2 + (y1-y2)2] ½ .

Addition of Two VectorsAddition of Two Vectors

(0,0) 2 4 6 8 10 12 14 16

2

4

6

8

a

b c

(8, 2)

(6, 6)

(14, 8)

c = a + b

= (8+6, 2+6)

Subtraction of Two VectorsSubtraction of Two Vectors

(0,0) 2 4 6 8 10 12 14 16

2

4

6

8

a

b c

(8, 2)

(6, 6)

(2, -4) c = (a – b)

= (8-6, 2-6)

Scalar Multiplication of a VectorScalar Multiplication of a Vector

(0,0) 2 4 6 8 10 12 14 16

2

4

6

8

a =ha =

(6, 4)(12, 8)

h = 2

Normal VectorNormal VectorA normal vector has a magnitude equal to one. Any vector a = (x, y) can be normalized as

a’ = (x’, y’), by dividing its respective components by its magnitude:

||

||

ay

ax

y

x

Inner Product of Two VectorsInner Product of Two Vectors

Inner product of two vectors is defined as the sum of the product of the respective components of the two vectors having the same number of components.

if a = (x1, y1) and b = (x2, y2), the inner product a·b = x1x2 + y1y2

The inner product of two vectors is also directly related to the angle between them, denoted by:

a · b = |a| |b| cosθ

The cosine of the angle between two vectors is found by:

cosθ= a · b / |a| |b|

Inner Product of Two VectorsInner Product of Two Vectors

MatrixMatrix A matrix is a rectangular array of numbers (referred to as elements) arranged in rows and columns.

A = a 11 a 12

a 21 a 22

Addition of Two MatricesAddition of Two MatricesIf two matrices have the same number of rows and columns, they can be added:

A = and B =

3 6

0 3

2 2

4 5

2 3

1 2

A + B =7 11

2 6

3 4

• The product AB of two matrices A and B is defined if and only if the number of columns in A is equal to the number of rows in B.

• If A is an m x p matrix and B is a p x n matrix, the resulting matrix C is an m x n matrix.

• Each element of AB is defined as the inner product of the ith row of A and the jth column of B: cij = ai1 b1j +ai2 b2j + ... + aip bpj

Product of Two MatricesProduct of Two Matrices

Product of Two MatricesProduct of Two Matrices

4 5

2 3

1 2

If A = , B = 3 0 2

6 3 2

then AB =

(4) (3) + (5) (6) (4) (0) + (5) (3) (4) (2) + (5) (2)

(2) (3) + (3) (6) (2) (0) + (3) (3) (2) (2) + (3) (2)

(1) (3) + (2) (6) (1) (0) + (2) (3) (1) (2) + (2) (2)

=

42 15 18

24 9 10

15 6 6

Some Important Matrices (1)Some Important Matrices (1)• The zero matrix is any matrix whose elements

are all zeroes• A square matrix is any matrix having as many

rows as columns• The identity matrix, denoted as I, is defined as

a square matrix whose diagonal elements are all ones and all other elements are zeroes

• Important properties of an identity matrix:

IA = AI = A

• The transposed matrix of a matrix A, denoted as AT, is formed by interchanging the rows and columns of A such that row i of A becomes column i of AT and column j of A becomes row j of AT

• The symmetric matrix S is a square matrix whose elements sij = sji. For symmetric matrix S, ST = S

• The reciprocal matrix of a square matrix A, denoted as A-1, is defined by its unique property:

AA-1 = I

Some Important Matrices (2)Some Important Matrices (2)

Determinant(Determinant( 行列式行列式 ) of a Square ) of a Square MatrixMatrix

• Determinant is a scalar associated with a square matrix

• Let C =

The determinant of C, denoted as |C|, is ascertained as:

|C| = (x1y2 – x2y1)

x1 x2

y1 y2

Usages of the DeterminantUsages of the Determinant

(0,0) 2 4 6 8 10 12 14 16

2

4

6

8

| C |

(4, 6)

(10, 2)

(14, 8)a =

b =

C = a, b

= 4 10

6 2

Homogeneous CoordinatesHomogeneous Coordinates• Homogeneous coordinates are the extension of

Cartesian coordinates from any dimension into the next higher dimension

• The homogeneous representation of a 2-D

point (x, y) is (hx, hy, h), where h is any non-zero scalar

• When h = 1, the homogeneous coordinate of 2-D point (x, y) is (x, y, 1)

Translation is used to offset the origin of the coordinate system in order to describe the positional changes of a point (x, y).

Suppose that Tx and Ty are increments on the X-axis and Y-axis of the new position of a point (x, y), then the new coordinates:

x‘ = x + Tx

y‘ = y + Ty

Translation (1)Translation (1)

Translation (2)Translation (2)

(0, 0)

(0, 0)

X

Y

X'

Y'(x', y')

(x, y)

x'

x

yy

Tx

Ty

( x' y' 1 ) = ( x y 1)

1 0 0

0 1 0

Tx Ty 1

= (x + Tx y + Ty 1)

• The rotation transformation is used to rotate the original coordinate system about the origin by some angle θ measured in the counter-clockwise direction from the X-axis

• The rotation tranformations are defined as:

x’ = x cosθ + y sinθ

y’ = -x sinθ + y cosθ

Rotation of the Rotation of the Coordinate System (1)Coordinate System (1)

Rotation of the Rotation of the Coordinate System (2)Coordinate System (2)

X

Y

(x, y)

X’

Y’

x

y

x’y’

(x’, y’)

θ

(x’ y’ 1) = (x y 1) cosθ -sinθ 0

sinθ cosθ 0

0 0 1

Rotation of the SymbolesRotation of the Symboles

0 10 20 30-10-20-30

10

20

30

40

X

Y

θ

A

B C

A’

B’

C’

x’ = x cosθ – y sinθ

y’ = x sinθ + y cosθ

Tr =

cosθ sinθ 0

-sinθ cosθ 0

0 0 1

(x’ y’ 1) = (x y 1) Tr

Scaling (1)Scaling (1)

0 10 20 30-10-20-30

10

20

30

40

X

A

B

C

Y

40

B’ C’

A’

E F

GH

E’ F’

G’H’

x’ = Sx · x

y’ = Sy · y

Scaling (2)Scaling (2)

X X

Y Y Sx = 0.5

Sy = 1

x’ = Sx · x

y’ = Sy · y

Concatenation of Point Concatenation of Point Transformation (1)Transformation (1)

Very often it is necessary to perform a sequence of point transformations known as concatenation. The matrix form of point transformation facilitates this process, because a series of transformations can be multiplied in order and stored in a single matrix that represents the whole transformation.

The sequence is important!

Given a translation matrix T, and a scaling matrix S, a new point p’ = p·T·S. It is not necessarily equal to p·S·T.

Concatenation of Point Concatenation of Point Transformation (2)Transformation (2)

The concatenated matrix C = T·S is defined as:

Concatenation of Point Concatenation of Point Transformation (3)Transformation (3)

The concatenated matrix C = S·T is defined as:

1 0 0

0 1 0

Tx Ty 1

Sx 0 0

0 Sy 0

0 0 1

=

Sx 0 0

0 Sy 0

TxSx TySy 1

Sx 0 0

0 Sy 0

0 0 1

1 0 0

0 1 0

Tx Ty 1=

Sx 0 0

0 Sy 0

Tx Ty 1

The Representation of a The Representation of a Straight LineStraight Line

Ax + By + C = 0

X

Y

Ax + By + C = 0

p (x1, y1)

q (x2, y2)

bm

A

B

C

(x y 1) = 0

y = mx + b;

Where m = (-A / B)

b = (-C/B) (-C/A)

Direction of a Line SegmentDirection of a Line Segment

A

B

C

A

B

C

y1 – y2

x2 – x1

y2x1 – y1x2

y2 – y1

x1 – x2

y1x2 – y2x1

=

=

Ax + By + C = 0 (0, 0) X

Y

pqv

| C |

• The two endpoints of a line segments can also define the straight line passing from p to q in a point-vector form:L = { (x1, y1) + h (x2 – x1, y2 –y1) | h R }∊

• The point-vector form preserves the direction of the line segment between p and q, and for any point lying on the line segment between p an q, the value of h will be in the closed interval [0, 1].For example if h = 0.5, then the point lies at the middle of the line segment.

Point-Vector FormPoint-Vector Form

Normalized Straight LineNormalized Straight Line

• A straight line L, is normalized by dividing its respective parameters by the magnitude of the vector between p and q, (A2 +B2) ½

A’

B’

C’=

A / (A2 + B2) ½

B / (A2 + B2) ½

C / (A2 + B2) ½

| v | = 1

A’x + B’y + C’ = 0

p’

q’

Questions for Review (1)Questions for Review (1)

• If two points p (1, 2) and q (4, 1) are given, what is the magnitude of the vector v starting from the point p and ending at the point q?

• If vector a = (1, 2), b = (4, 3), what is (a + b)? What is (a – b)? What is the angle between these two vectors?

• Suppose A =

Questions for Review (2)Questions for Review (2) 4 5

2 3

1 2

B = 3 0 2

6 3 2

What is the product of AB? Does the product BA exist? If it exists, what is BA?

• What do the point transforming matrices look like for translation of a point, rotation of the point of the symbol, and scaling the symbol?

• Why is the concatenation of the matrices for point transformation important? What are the advantages of the concatenation?

• Why can one say that it is important to study the point and line relationships in digital cartography? ****(Many cartographic functions utilize point and line relationships)

Questions for Review (3)Questions for Review (3)