Consider the Following Frequently Used 2-D Transformations

Question #1: (35%) [Theoretical Question]

Consider the following frequently used 2-D transformations:

1) Translation: x′ = x + s y′ = y + t

The point (x,y) is moved by vector (s,t)

2) Scaling: x′ = ax y′ = by

x-axis distances are magnified by a; y-axis distances are magnified by b

3) Rotation: x′ = x cosθ − y sinθ y′ = xsinθ + y cosθ

The point (x,y) is rotated through an angle θ about (0,0)

4) Reflection: x′ = x y′ = − y

The point (x,y) is reflected about the x-axis

5) Shear: x′ = x + hy y′ = y

The point (x,y) is shifted in the x-direction by the amount hy

a) Express the above transformation in matrix form in homogenous coordinates.

1)

1 / 0 / s / x / x + s
0 / 1 / t / * / y / = / y + t
0 / 0 / 1 / 1 / 1

2)

a / 0 / 0 / x / xa
0 / b / 0 / * / y / = / yb
0 / 0 / 1 / 1 / 1


3)

cos θ / -sin θ / 0 / x / x cos θ - y sin θ
sin θ / cos θ / 0 / * / y / = / x sin θ + y cos θ
0 / 0 / 1 / 1 / 1

4)

1 / 0 / 0 / x / x
0 / -1 / 0 / * / y / = / -y
0 / 0 / 1 / 1 / 1

5)

1 / 0 / hy / x / x + hy
0 / 1 / 0 / * / y / = / y
0 / 0 / 1 / 1 / 1

b) Determine the form of a transformation matrix for a rotation by an angle t about the point (e,f) followed by a translation by the vector (c,d) followed by a scaling with respect to (e,f) by the values (a,b).

a / 0 / 0 / 1 / 0 / c / cos t / -sin t / 0 / a cos t / -a sin t / ac
0 / b / 0 / * / 0 / 1 / d / * / sin t / cos t / 0 / = / b sin t / b cos t / bd
0 / 0 / 1 / 0 / 0 / 1 / 0 / 0 / 1 / 0 / 0 / 1

c) Prove that a rotation by an angle θ1 followed by a rotation by an angle θ2 is equivalent to a single rotation by an angle θ1 + θ2.

cos θ2 / -sin θ2 / 0 / cos θ1 / -sin θ1 / 0
sin θ2 / cos θ2 / 0 / * / sin θ1 / cos θ1 / 0 / =
0 / 0 / 1 / 0 / 0 / 1
cos θ2 * cos θ1 - sin θ2 * sin θ1 / - cos θ2 * sin θ1 - sin θ2 * cos θ1 / 0
sin θ2 * cos θ1 + cos θ2 * sin θ1 / cos θ2 * cos θ1 - sin θ2 * sin θ1 / 0
0 / 0 / 1

Using the formulas, and defining θ2 = a, θ1 = b:

sin a sin b = ½[cos(a - b) - cos(a + b)]

cos a cos b = ½[cos(a - b) + cos(a + b)]

sin a cos b = ½[sin(a + b) + sin(a - b)]

cos a sin b = ½[sin(a + b) - sin(a - b)]

cos a * cos b - sin a * sin b = ½[cos(a - b) + cos(a + b)] - ½[cos(a - b) - cos(a + b)] = cos(a + b)

cos a * sin b - sin a * cos b = ½[sin(a + b) - sin(a - b)] - ½[sin(a + b) + sin(a - b)] = -sin(a + b)

therefore,

cos θ2 * cos θ1 - sin θ2 * sin θ1 / - cos θ2 * sin θ1 - sin θ2 * cos θ1 / 0
sin θ2 * cos θ1 + cos θ2 * sin θ1 / cos θ2 * cos θ1 - sin θ2 * sin θ1 / 0 / =
0 / 0 / 1
cos (θ2 + θ1) / -sin (θ2 + θ1) / 0
sin (θ2 + θ1) / cos (θ2 + θ1) / 0
0 / 0 / 1

d) Two transformations that give the same final result regardless of the order in which they are applied are called commutative. Prove that rotation followed by a rotation are commutative operations. Prove that translation and scaling are not commutative. Likewise, prove that rotation and scaling are not commutative unless a=b.

rotation followed by rotation:

a / -b / 0 / c / -d / 0 / ac - bd / -ad - bc / 0
b / a / 0 / * / d / c / 0 / = / ad + bc / ac - bd / 0
0 / 0 / 1 / 0 / 0 / 1 / 0 / 0 / 1

=

c / -d / 0 / a / -b / 0 / ca - db / -da - cb / 0
d / c / 0 / * / b / a / 0 / = / da + cb / ca – db / 0
0 / 0 / 1 / 0 / 0 / 1 / 0 / 0 / 1

translation followed by scaling:

a / 0 / 0 / 1 / 0 / S / a / 0 / as
0 / b / 0 / * / 0 / 1 / T / = / 0 / b / bt
0 / 0 / 1 / 0 / 0 / 1 / 0 / 0 / 1

is not equal to scaling followed by translation:

1 / 0 / s / a / 0 / 0 / a / 0 / s
0 / 1 / t / * / 0 / b / 0 / = / 0 / b / t
0 / 0 / 1 / 0 / 0 / 1 / 0 / 0 / 1

scaling followed by rotation:

a / -b / 0 / c / 0 / 0 / ac / -bd / 0
b / a / 0 / * / 0 / d / 0 / = / bc / ad / 0
0 / 0 / 1 / 0 / 0 / 1 / 0 / 0 / 1

is not equal to rotation followed by scaling:

c / 0 / 0 / a / -b / 0 / ca / -cb / 0
0 / d / 0 / * / b / a / 0 / = / db / da / 0
0 / 0 / 1 / 0 / 0 / 1 / 0 / 0 / 1

e) Determine the form of transformation matrix for a reflection about an arbitrary line y = mx + b.

A reflection about an arbitrary line can be expressed as a combination of translations and rotations, and a reflection about the x-axis. Essentially, translate the line such that it passes through the origin, and then rotate the line such that it becomes the x-axis, perform the reflection, then translate and rotate back.

T / Q / R
1 / 0 / 0 / 1 / 0 / 0 / cos θ / sin θ / 0
0 / 1 / -b / 0 / -1 / 0 / -sin θ / cos θ / 0
0 / 0 / 1 / 0 / 0 / 1 / 0 / 0 / 1
T-1 / R-1
1 / 0 / 0 / cos θ / -sin θ / 0
0 / 1 / b / sin θ / cos θ / 0
0 / 0 / 1 / 0 / 0 / 1

M = T-1R-1QRT

T-1R-1 = A1

T-1 / R-1 / A1
1 / 0 / 0 / cos θ / -sin θ / 0 / cos θ / -sin θ / 0
0 / 1 / b / * / sin θ / cos θ / 0 / = / sin θ / cos θ / b
0 / 0 / 1 / 0 / 0 / 1 / 0 / 0 / 1

A1Q = A2

A1 / Q / A2
cos θ / -sin θ / 0 / 1 / 0 / 0 / cos θ / sin θ / 0
sin θ / cos θ / b / * / 0 / -1 / 0 / = / sin θ / -cos θ / b
0 / 0 / 1 / 0 / 0 / 1 / 0 / 0 / 1

A2R = A3

A2 / R / A3
cos θ / sin θ / 0 / cos θ / sin θ / 0 / cos2 θ – sin2 θ / 2 sin θ cos θ / 0
sin θ / -cos θ / b / * / -sin θ / cos θ / 0 / = / 2 sin θ cos θ / sin2 θ - cos2 θ / b
0 / 0 / 1 / 0 / 0 / 1 / 0 / 0 / 1

A3T = M

A3 / T / M
cos2 θ – sin2 θ / 2 sin θ cos θ / 0 / 1 / 0 / 0 / cos2 θ – sin2 θ / 2 sin θ cos θ / -2b sin θ cos θ
2 sin θ cos θ / sin2 θ - cos2 θ / b / * / 0 / 1 / -b / = / 2 sin θ cos θ / sin2 θ - cos2 θ / -b (sin2 θ - cos2 θ) + b
0 / 0 / 1 / 0 / 0 / 1 / 0 / 0 / 1

To simplify this, tan θ = m, and thus cos θ = 1/(√1+m2) and sin θ = m/(√1+m2). Therefore,

M
(1 – m2)/(1 + m2) / 2m / (1 + m2) / -2bm / (1 + m2)
2m / (1 + m2) / (m2 - 1)/(1 + m2) / 2b / (1 + m2)
0 / 0 / 1

Question #2: (10%) [Theoretical Question]

a) Assume that four 3-D points, P1, P2, P3, P4 are given. How will you determine whether these points are coplanar, i.e., lie in the same plane?

Assuming that the four points are all given in (x, y, z) format, two points will lie in the same plane if (x1 = x2), (y1 = y2), or (z1=z2), IE if they share the same x, y, or z coordinate. For all points to be coplanar, they must all share the same x, y, or z coordinate.

b) Given 3-D points P and Q and a plane through point P0 with normal N find an algorithm to clip a line segment between points P and Q against the plane.

In each case, where applicable, please give complete formulae.

Question #3: (15%) [Theoretical Question]

This question deals with the graphics hardware.

a) Consider three different raster systems with resolutions of 640 by 480, 1280 by 1024, and 2560 by 2048. What size frame buffer (in bytes) is needed for each of these systems to store 24 bits per pixel?

640 x 480: 640*480*24/8 = 921600 bytes ~= 1mb

1280 x 1024: 1280*1024*24/8 = 3932160 bytes ~= 4mb

2560 x 2048: 2560*2048*24/8 = 15728640 bytes ~= 16mb

b) How long would it take to load 12-bit per pixel frame buffer with a resolution of 640 by 480 using the transfer rate of $105$ bits per second? What about the same question for 24-bit per pixel frame buffer and resolution of 1280 by 1024?

12 bits per pixel, 640 x 480 resolution = 640*480*12/8 = 460800 bytes ~= 460kb

105 bits per second = 105/8 = 12500 bytes per second.

Total time = 460800 bytes / 12500 bytes per second = 36.864 seconds

24 bits per pixel, 1280 x 1024 resolution = 1280*1024*24/8 = 3932160 bytes ~= 4mb

105 bits per second = 105/8 = 12500 bytes per second.

Total time = 3932160 / 12500 = 314.5728 seconds

c) Suppose we have a video monitor with a display area which measures 12 inches across and 9.6 inches high. If the resolution is 1280 by 1024 and the aspect ratio is 1, what is the diameter of each screen point?

An aspect ratio of 1 means that each pixel has the same height and length, and there are 1024 pixels per line. 9.6 inches is 243.84 mm, therefore each pixel must have a diameter of 243.84 / 1024 = 0.238125mm.

Question #4: (10%) [Theoretical Question]

The resolution of photographic film is limited by the wavelength of light, which ranges from 400 nm to 750 nm, where 1 nm = 10-9 m. For slow color transparency film, the effective resolution is about 1,000 lines/mm.

a) Assuming that colour encoding requires 24 bits/pixel, calculate the number of bytes required to digitize one frame of 35 mm film without any loss of clarity. The size of the frame is 24 mm x 36 mm.

24 bits/pixel = 3 bytes/pixel.

1000 lines/mm * 24 mm x 36mm = 24000 lines x 36000 lines

b) Using the same assumptions, calculate the number of bytes required to digitize one frame of $8 in x 10 in sheet film.

1 inch = 25.4 millimeters, therefore 8 inch x 10 inch = 203.2 mm x 254 mm.