• No results found

3eChap5 Exercise Solutions

N/A
N/A
Protected

Academic year: 2021

Share "3eChap5 Exercise Solutions"

Copied!
23
0
0

Loading.... (view fulltext now)

Full text

(1)

Chapter 5 – Solutions to Selected Practice Exercises

Solutions to Selected exercises for Chapter 5 (preliminary version) 5.2.2. Solution: Sketch the effect.

(Qx, Qy) = (SxPx, SyPy) Sx = 3, Sy = -2

a). The circle scales into an ellipse 3 times as wide and twice as high;

b). The square scales to a rectangle 3 times as wide and twice as high, as well as being upside down; The points of the square scale as shown:

(1,1), (1, 2), (2, 2), (2,1) → (3, -2), (3, -4), (6, -4), (6, -2)

5.2.4. Solution: Shearing Lines.

Use Qx= Px, Qy = gPx + Py

Each line is transformed into another straight line (this will be proved in general subsequently), with transformed endpoints:

a) (-3, 2.8), (2, 4.8) b) (-3, -5.2), (2, -3.2) c) (-2, 4.2), (-2, -1.8) d) (-1, -2.4), (3, 3.2)

The given figures in F5.12 shear into the figures with new points: a) (-1,0), (0,1), (1,0), (0, -1) → (-1, 0), (0, 1), (1, 0.4), (0, -1) b) (0,0), (0,1), (1,1), (1, 0) → (0, 0), (0, 1), (1, 1.4), (1, 0.4) c) (1,1), (1, 2), (2, 2), (2,1) → (1, 1.4), (1, 2.4), (2, 2.8), (2, 1.8)

(2)

5.2.5.

Solution: To invert a Shear.

By the equation 5.11 and 5.12:

M−1=

1

0

0

0

1h

-

0

1

/(1-gh). This is a shear only if gh = 0

5.2.7. Solution: An Inverse Matrix.

By direct calculation ( see Appendix 2 for methods and details:M =

1

0

0

0

1

1-1

2

3

M−1=

1 .

0

0 .

0 . 2

-

0 . 6

0 . 2

0 . 2

-

0 . 4

-

0 . 2

(3)

5.2.8. Solution:

Fixed Points of an Affine Transformation.

a) when the third column of M is (0,0,1), M=

          1 0 0 31 31 22 21 12 11 M M M M M M M (0, 0, 1)T =           1 0 0 31 31 22 21 12 11 M M M M M M (0, 0, 1) T = (0, 0, 1) T

Origin is a fixed point

b) T(P) = T(P-F+F) = T(P-F)+T(F) = M(P - F)+ F. c) Point V is the fixed point for a rotation about point V. MV=           − 1 0 0 ) cos( ) sin( ) sin( ) cos( y x d d θ θ θ θ (Vx, Vy, 1)T

=(Vx cos(θ)−VY sin(θ)+dx,Vxsin(θ)+VY cos(θ)+dy,1)

Since y y x y x y x x V V V d V V V d + − − = + + − = ) cos( ) sin( ) sin( ) cos( θ θ θ θ

MV= (Vxcos(θ)−VY sin(θ)+dx,Vxsin(θ)+VY cos(θ)+dy,1 ) =(Vx,Vy,1)

Point V is the fixed point for a rotation about point V.

e) Point V is the fixed point for a scaling with scale factors Sx and Sy, about V.

f) T(T(P)) = T(M(P - F)+ F) = M2(P - F)+ F

T(T(T(P))) = T(M2(P - F)+ F) = T(M2(P - F))+ T(F)= M3(P - F)+ F

T(T(T(T(P)))) = T(M3(P - F)+ F) = T(M3(P - F))+ T(F)= M4(P - F)+ F

T(T(T(T(T(P))))) = T(M4(P - F)+ F) = T(M4(P - F))+ T(F)= M5(P - F)+ F

5.2.9. Solution: To Find Matrices.

a)                     − −           −           1 0 0 0 1 0 0 0 2 1 0 0 1 1 0 2 0 1 1 0 0 0 ) cos( ) sin( 0 ) sin( ) cos( 1 0 0 1 1 0 2 0 1 θ θ θ θ . b)           + +           1 0 0 3 3Sy -Sy 0 2 2S -0 S 1 0 0 1 1 0 1 0 1 x x

(4)

c)

1

0

0

1-

1

0

1-

0

1

1

0

0

0

1

0

0

0 . 3

1

10

0

01

0

00

2

10

0

0

2

3

5.0

05.0

2

3

10

0

11

0

10

1

=

1

0

0

3 0.

1 . 1 6 5

1

2 . 0 1

-

0 . 1 9

2 . 3 1

5.2.10. Solution: To Normalize a Box.

The given box is a rectangle, with its lower edge tiled at angle θ = 30°

1. rotate through -30° 2. scale by (1/w, 1/2w), where w = 5 M =                   −                 1 0 0 0 2 3 2 1 0 2 1 2 3 1 0 0 0 5 2 1 0 0 0 5 1 =

1

0

0

0

0 . 1 9 3 3

0 . 1 1 1 8

0

0 . 2 2 3 5

-

3 8 6 7

.0

5.2.11. Solutions: Some Transformations Commute.

(5)

S⋅ R =         1 0 0 0 S 0 0 0 S y x ⋅           − 1 0 0 0 ) cos( ) sin( 0 ) sin( ) cos( θ θ θ θ =         1 0 0 0 cos S sin S 0 sin S -cos S y y x x θ θθ θ R⋅ S =           − 1 0 0 0 ) cos( ) sin( 0 ) sin( ) cos( θ θ θ θ ⋅         1 0 0 0 S 0 0 0 S y x =         1 0 0 0 cos S sin S 0 sin S -cos S y x y x θ θθ θ

For uniform scaling, Sx = Sy, S⋅R = R⋅ S. So the uniform scaling commutes with

rotation.

The differential scaling does not commute with rotation.

5.2.12. Solutions: Reflection plus a rotation.

Reflection: 1. reflection in x 2. reflection in y M1 =       − 1 0 0 1 0 01 0 0 ⋅         − 1 0 0 1 0 0 0 0 1 =         − − 1 0 0 1 0 01 0 0 Rotate 180° M2 =

° ° ° °

1

0

0

cos

180

0

180

sin

180

sin

180

0

cos

=         − − 1 0 0 1 0 01 0 0 M1 = M2

So a reflection in x followed by a reflection in y is the same as a rotation by 1800.

5.2.13. Solution: Two Successive Rotations.

Rotation

1. rotation through angle θ 1, R(θ 1) 2. rotation through angle θ 2, R(θ 2)

        − 1 0 0 0 cos sin 0 sin cos 2 2 2 2

θ

θ

θ

θ

       − 1 0 0 0 cos sin 0 sin cos 1 1 1 1

θ

θ

θ

θ

=        + − +− − − 1 0 0 0 cos cos sin sin sin cos cos sin 0 cos sin sin cos sin sin cos cos 1 2 1 2 1 2 1 2 1 2 1 2 1 2 1 2

θ

θ

θ

θ

θ

θ

θ

θ

θ

θ

θ

θ

θ

θ

θ

θ

(6)

=        + ++ − + 1 0 0 0 ) cos( ) sin( 0 ) sin( ) cos( 1 2 1 2 1 2 1 2

θ

θ

θ

θ

θ

θ

θ

θ

= R (θ 1 + θ 2)

R( 1) followed by R() is equivalent to applying the single rotation R(1 + ). Thus

successive rotations are additive.

5.2.14. Solutions: A Succession of Shears

        1 0 0 0 1 0 0 1 g         1 0 0 1 0 0 0 1 h =        + 1 0 0 0 1 0 1 gh g h Which is a shear if gh = 0.

5.2.24 Solution: The argument generalized.

W = a1 P1 + a2 P2 + … + aN PN where a1 + a2 + … + aN = 1

T(W) = T(a1 P1 + a2 P2 + … + aN PN) = a1 T(P1) + a2 T(P2) + … + aN T(PN)

5.2.25. Solutions: Show that relative ratios are preserved.

P = A + bt where b = B - A.

So P = A + bt = A + (B – A)t = (1 - t) A + t B |P - A| = | t B – t A| = t |B – A|

|P - B| = | (1– t) A +(t -1) B | = |(1 - t) (B – A)| = (1 - t) |A – B| = (1 - t) |B – A| This is true if t lies outside of the range 0 to 1 because t + (1 – t) = 1.

T(P) = (1 - t) T(A) + t T(B)

|T(P) - T(A)| = | - t T(A) + t T(B)| = t | T(B) – T(A)| |T(P) - T(B)|.= (1 - t) | T(B) – T(A)|

Exercise 5.3.1.

Solution.

Yes, by direct visualization, 90o rotations about each axis rotate each axis into

another To visualize the 90° .

Rotating a point on the x – axis about the x – axis has no effect for the point.

Rotations

(7)

Q =

=





=





1

11 0

0 0

0 0

1 0

0 1-

0 0

0 0

0

1

11 0

0 0

0 c

s 0

0 s

- c 0

0 0

0

1

y

z

x

z

y

x

z

y

x

(8)

Also we can get the familiar results for y – roll and z – roll. So a 90° rotation about each

axis rotates the other axes into one another.

Exercise 5.3.2. To Rotate the Basic Barn.

Sketching not done here.

5.3.3. Solution: Do a Rotation, a –roll of 45 degrees.

Q =

=

−

1

0

2

0

1

1

2

1

1 0

0

0

s-

c 0

0

0

0

1

0

0

s

0

c

, where c = s = 0.707, based on a rotation by 45 degrees.

This is reasonable since the y-coord Is not affected, due to the placement of zeroes in the matrix.

(9)

5.3.4. Solution: Test 90° Rotations of the Axes. cos90°= 0, sin90°=1 For x – roll, Qxi =

1

0

0

0

1

0

0

0

0

1-

0

0

0

0

0

1

1

0

0

1

=

1

0

0

1

Qxj =

1

1

0

0

Qxz =

1

1

1

0

i → i ; j → k ; k → -j for y-roll, Qyi =





1

1

0

0

Qyj =





1

0

1

0

Qyz =

1

0

0

1

i → -k ; j → j ; k → i for z-roll,

(10)

Qzi =





1

0

1

0

Qzj =





 −

1

0

0

1

Qzk =

1

1

0

0

i → k ; j → -i ; k → k

(11)

Qx =

+

=





1

c z

s y

s z-cy

x

11 0

0 0

0

c

s 0

0

s- c 0

0 0

0

1

z

y

x

= (x, cy-sz, sy + cz)

Qcurrent = x, Qnext = cy – sz, Q prev = sy + cz , Pcurrent = x, Pnext = y, P prev = z

Also

Q y = (cx + sz, y, cz – sx)

Qcurrent = y, Qnext = c z – sx, Qprev = sz + cx , Pcurrent = y, Pnext = z, Pprev = x

Qz = (cx - sy, sx + cy, z)

Qcurrent = z, Qnext = c x – sy, Qprev = sx + cy , Pcurrent = z, Pnext = x, P prev = y 5.3.6. Solution: Which ones commute?

a) pure translations : T1T2 = T2 T1: yes, commute.

b) both are scaling :

(12)

T1T2 =

=

1

0

0

0

0

SS

0

0

0

0

SS

0

0

0

0

SS

1

0

0

0

0 S

0

0

0

0 S

0

0

0

0

S

1

0

0

0

0 S

0

0

0

0 S

0

0

0

0

S

z 2

z 1

y 2

y 1

x 2

x 1

z 2

y 2

x 2

z 1

y 1

x 1

= commute. T2 T1 c) shear: T1T2 =





1

0

0

0

0

1

0

0

0

0

1 f

0

0

0

1





1

0

0

0

0

1

0

0

0

0

1

0

0

0

k

1

=





+

1

0

0

0

0

1

0

0

0

0

f k

1

f

0

0

k

1

(13)

T2 T1 =





1

0

0

0

0

1

0

0

0

0

1

0

0

0

k

1





1

0

0

0

0

1

0

0

0

0

1 f

0

0

0

1

=





 +

1

0

0

0

0

1

0

0

0

0

1

f

0

0

k

f k

1

They commute if fk = 0. d) A rotation and a translation for example x – roll

T1T2 =





1

0

0

0

0

c

s

0

0

s-

c

0

0

0

0

1

            1 0 0 0 1 0 0 0 1 0 0 0 1 34 24 14 m m m =             1 0 0 0 c -s c 0 s -c s -c 0 0 0 1 34 24 34 24 14 m m s m m m T2 T1 =             1 0 0 0 1 0 0 0 1 0 0 0 1 34 24 14 m m m





1

0

0

0

0

c

s

0

0

s-

c

0

0

0

0

1

=             1 0 0 0 c 0 s -c 0 0 0 1 24 24 14 m s m m

T1T2 is not the same as T2 T1. Familiar with x-roll, we can get the same result by y –

roll and z – roll.

e) A rotation and a scaling for example x – roll

(14)

T1T2 =





1

0

0

0

0

c

s

0

0

s-

c

0

0

0

0

1

            1 0 0 0 0 0 0 0 0 0 0 0 0 z y x S S S =             − 1 0 0 0 0 c s 0 0 s c 0 0 0 0 z y z y x S S S S S T2 T1 =             − 1 0 0 0 0 c s 0 0 s c 0 0 0 0 z z y y x S S S S S

T1T2 is not the same as T2 T1.

f) a scaling and a shear, for example in x-axes shear

T1T2 =             1 0 0 0 0 0 0 0 0 0 0 0 0 z y x S S S





1

0

0

0

0

1

0

0

0

0

1

0

0

0

k

1

=             1 0 0 0 0 0 0 0 0 0 0 0 z y x x S S kS S T2 T1 =             1 0 0 0 0 0 0 0 0 1 0 0 0 z y x S kS S

T1T2 is not the same as T2 T1.

5.3.7. Solution: Special cases of rotation about a general axis u.

Using Equation 5.33 a) X- axis, i

(15)

Ru (β ) =





1

0

0

0

0

c

s

0

0

s-

c

0

0

0

0

1

It’s the same as x – roll.

We also can get the familiar results of y – axis, j ; z – axis , k.

5.3.8. Solution: Classic Approach to Rotation about an Axis.

It’s Equation 5.32.

Ru( ) = Rz( - ) Ry( - ) Rz( )  Ry( )  Rz( )

(16)

=

−

−−

−−

−−

−−−

1

0

0

0

0

1

0

0

0

0

c o s

s i n

0

0

s i n

-

c o s

1

0

0

0

0

c o s

0

s i n

-0

0

1

0

0

s i n

0

c o s

1

0

0

0

0

1

0

0

0

0

c o s

s i n

0

0

s i n

c o s

1

0

0

0

0 )

c o s (

0

)s i n (

-0

0

1

0

0

)s i n (

0

)c o s (

1

0

0

0

0

1

0

0

0 0

)c o s (

)s i n (

0 0

)s i n (

)c o s (

φφ

φφ

φφ

φφ

ββ

ββ

φφ

φφ

θθ

θθ

(17)

Where θ = 30° cosθ = 0.866, sinθ = 0.5;

φ = 45° cosφ = 0.707, sinφ = 0.707;

β = 35° cosβ = 0.819, sinβ = 0.5735

So we can get the final result is:

            − − − = 1 0 0 0 0 910 . 396 . 124 . 0 306 . 842 . 445 . 0 281 . 366 . 877 . ~ M 5.3.9. Solution: Orthogonal Matrices.

By direct calculation each of the three rotation matrices has orthogonal columns (and rows), each of length 1. The determinant of an orthogonal matrix is 1. Partition orthogonal matrix M into its columns:

M = (c1| c2 | c3), so MT=

T

T

T

c 3

c 2

c 1

. Now note that M MT= I, the identity matrix, due to

the properties of the columns. So MT= M-1.

5.3.10. Show that the Matrix of Equation 5.33 Is Orthogonal.

Based on the hint that accompanies this problem we need only show that the product of two orthogonal matrices is orthogonal. Suppose A and B are orthogonal, and set C =

A * B. Now examine C-1.

We must show C-1 is the same as CT. But for any matrix C the inverse can be written as

the reversed product of its individual inverses, so C-1 = B-1 * A-1, and since these guys are

orthogonal, we have C-1 = BT * AT.

Now since the transpose of a product can be written as the product of transposes (but reverse their order), C-1 = (A*B)T, so yes indeed, C-1is CT!

(18)

5.3.11. Solution: Structure of a rotation matrix.

Use Equation 5.33, where c is cos, s is sin a) The first row ⋅ the second row is: [c + (1-c)u2

x ]i⋅[(1– c)ux u y+ suz]i + [(1– c)ux u y- su z]k⋅ [c + (1-c)u

2 y]k + [(1– c)ux uz+ suy ]j⋅ [(1– c)uzuy - sux ]j = 2c(1-c)ux u y+ (1- c)2 u3x u y+ (1- c)2 u3yux + (1-c)u2z ux uy -s2 ux uy = (1- c)2 u xu y( -1 + u2x+ u 2 y + u2z ) = 0

They are orthogonal.

Also there are the first⋅ the third = 0; the second⋅ the third = 0 b) Use Equation 4.28

First × Second = Third

5.3.12. Solution: What if the axis of rotation does not pass through the origin?

1. translate to the origin through –S 2. apply the rotation

3. translate back through S

            1 0 0 0 1 0 0 0 1 0 0 0 1 z y x S S S

+

+

+

+

+

+

1

0

0

0

0

)

1

(

)

1

(

)

1

(

0

)

1

(

)

1

(

)

1

(

0

)

1

(

)

1

(

)

1

(

2 2 2 z x z y y z x x y z y z y x y x z z x y x

u

c

c

su

u

u

c

su

u

u

c

su

u

u

c

u

c

c

su

u

u

c

su

u

u

c

su

u

u

c

u

c

c

            − − − 1 0 0 0 1 0 0 0 1 0 0 0 1 z y x S S S =

+

+

+

+

+

+

+

+

+

+

+

+

+

+

+

1

0

0

0

]

)

1

(

[

]

)

1

[(

]

)

1

[(

)

1

(

)

1

(

)

1

(

]

)

1

[(

]

)

1

(

[

]

)

1

[(

)

1

(

)

1

(

)

1

(

]

)

1

[(

]

)

1

[(

]

)

1

(

[

)

1

(

)

1

(

)

1

(

2 2 2 2 2 2 y z z x z y y y z x x z x z y y z x y x y z z y y z x x y z y z x y x z z z x y y x x y x z z x y x

S

u

c

c

S

su

u

u

c

S

su

u

u

c

S

u

c

c

su

u

u

c

su

u

u

c

S

su

u

u

c

S

u

c

c

S

su

u

u

c

S

su

u

u

c

u

c

c

su

u

u

c

S

su

u

u

c

S

su

u

u

c

S

u

c

c

S

su

u

u

c

su

u

u

c

u

c

c

5.4.1. Solution: How transforming a coordinate system relates to transforming a

(19)

Suppose we have a 2D coordinate frame #1 as shown in Figure 5.31, with origin ϑ and axes i and j. Further suppose we have an affine transformation T(.) represented by matrix M. So T(.) transforms coordinate frame #1 into coordinate frame #2, with new origin ϑ’ = T(ϑ), and new axes i’ = T(i) and j’ = T(j).

i’= M(1, 0, 0)T = Mi ; j’= M(0, 1, 0)T = Mj ci’ + dj’ + ϑ ’ = cM(1, 0, 0)T + dM(0, 1, 0)T+ M(0, 0, 1)T= c Mi + d Mj + Mϑ M(c, d, 1)T= M

1

d

c

= c Mi + d Mj + Mϑ M(c, 0, 0)T+ M(0, d, 0)T + M(0, 0, 1) T = c Mi + d Mj + Mϑ

ci’ + dj’ + ϑ ’ is the same as M(c, d, 1)T and M(c, 0, 0)T+ M(0, d, 0)T + M(0, 0, 1) T.

The same result in Equation 5.35.

5.4.2. Solution: Using elementary examples.

a) P =

11

00

10

01

f

e

n

m

=

+

+

1

n

f

m

e

The point (e, f) in the new system lies at (e + m, f + n) in the original system.

(20)

b) P =

11

0

0

0

c o s

s i n

0

s i n

-c o s

f

e

A

A

A

A

=

+

1

c o s

s i n

s i n

c o s

A

f

A

e

A

f

A

e

The point (e, f) in the new system lies at (e cos(a) - f sin(a), e sin(a) + f cos(a)), where a = A / 180 radians.  c) P =

11

00

02

0

00

3

f

e

=

1

2

3

f

e

The point (e, f) in the new system lies at (3e, 2f) in the original system.

d) P =

11

00

01

0

00

1

f

e

=

1

f

e

(21)

5.5.3. Solution: A hexagonal tiling.

a)  OAB is equilateral So OA=AB=R

Length of a hexagon is R too

b) The distance between two rows can be expressed as: OO’= 2OC = 2 OA .Sin60 = 3 R

The distance between two columns can be expressed as: OE= OD+DE=R+ OA .Cos60=23 R

c)

# define PI 3.1415926

cvs.pushCT(); // so we can return here

cvs.translate2D(0, 0); // position in origin for the first motif for(i = 0; i < numberofColumns; i++)// for each column

{

cvs.pushCT();

for(j = 0; j <numberofRows; j++) // for each row {

drawmotif(); // move to the right

cvs.translate2D(0, 2* sin(PI/3.)*R); }

// back to the start of this column cvs.popCT();

(22)

// move to the next column

cvs.translate2D(1.5*R,pow(-1,i+1)* sin(PI/3.)*R); }

cvs.popCT();

5.6.1. Solution: What does gluLookAt() do?

a). u n v n up u n × = × = − =eye look

So that u.v = 0; u.n = 0; n.v = 0;

u, v, and n are mutually perpendicular.

b) ) 1 , . , . , . ( 1 0 0 0 z y x d n n n d v v v d u u u V z z y x y z y x x z y x eye eye eye eye             = ⋅

= (eyeu+dx,eyev+dy,eyen+dz, 1)

=(eyeueyeu,eyeveyev,eyeneyen, 1)

=(0,0, 0, 1) ) 0 , . , . , . ( 1 0 0 0 z y x d n n n d v v v d u u u V z z y x y z y x x z y x u u u u             = ⋅ = (uu,uv,un, 0) =(1,0, 0, 0) Similarly, Vv= (0,1, 0, 0) Vn =(0,0, 1, 0) c) look eye − = n = (4, 3, 4) n up u= × =

4

3

4

0

1

0

k

j

i

= (4, 0,-4)

(23)

u

n

v

=

×

= (-12, 32, -12) Normalize u, v, and n,

n

= (0.70711, 0, 0.70711)

u

= (-0.3313, 0.8834, - 0.3313)

v

= (0.6247, 0.4685, 0.6247) dx =-eye.u =(4, 4, 4) . (-0.3313, 0.8834, - 0.3313) = 0 dy =-eye.v =(4, 4, 4) . (0.6247, 0.4685, 0.6247) = -0.88345 dz =-eye.n =(4, 4, 4) . (0.70711, 0, 0.70711) = -6.872 So that,             − − − − − = 1 0 0 0 872 . 6 6247 . 4685 . 6247 . 88345 . 3313 . 88345 . 3313 . 0 70711 . 0 70711 . V

5.6.2. Inquiring of the values in a matrix in OpenGL.

This solution not included.

5.6.3. Inquiring of the values in a matrix in OpenGL.

This solution not included.

References

Related documents