## COMP3421 – Lec 2 – Transformations

## Homogeneous Coordinates

Interestingly we can use the extra dimension in homogeneous coordinates to distinguish a point from a vector. A point will have a 1 in the last component, and a vector will have a 0. The difference between a point and a vector is a bit wish washy in my mind so I’m not sure why this distinction helps.

## Transforming a Point

Say we have the 2D point . This point as a column vector in homogeneous coordinates is . For a multiplication between this vector and a transformation matrix (3 by 3) to work we need to do the matrix times the vector (in that order) to give the translated vector, .

## Combining Transformations

Say we want to do a translation then a rotation (A then B) on the point x. First we must do , then . That is . The order is important as matrix multiplication in not commutative, ie. (just think a translation then a rotation is not necessarily the same as a rotate then a move (by the same amounts)). If we do lots of transformations we may get something like , this is in effect doing transformation A then B then C then D. (Remember matrix multiplication is associative, i.e. ).

As a side note, if you express your point as a row vector (eg. ), then to do a transformation you must do (where x is the point/row vector). In this case is equivalent to doing transformation A on point x, then transformation B then C (apparently this is how DirectX works).

## Affine Transformations

Affine transformations are a special kind of transformation. They have a matrix form where the last row is [0 … 0 1]. An affine transformation is equivalent to a linear transformation followed by a translation. That is, is the same as .

Something interesting to note is, the inverse transformation of an affine transformation is another affine transformation, whose matrix is the inverse matrix of the original. Also an affine transformation in 2D is uniquely defined by its action on three points.

From page 209 of the text (Hill, 2006), affine transformations have some very useful properties.

### 1. Affine Transformations Preserve Affine Combinations of Points

For some affine transformation T, points P_{1} and P_{2}, and real’s a_{1} and b_{1} where a_{1} + b_{1} = 1,

### 2. Affine Transformations Preserve Lines and Planes

That is under any affine transformation lines transformed are still lines (they don’t suddenly become curved), similarly planes that are transformed are still planes.

### 3. Parallelism of Lines and Planes is Preserved

“If two lines or planes are parallel, their images under an affine transformation are also parallel.” The explanation that Hill uses is rather good,

Take an arbitrary line A + **b**t having direction **b**. It transforms to the line given in homogeneous coordinates by M(A + **b**t) = MA + (M**b**)t, this transformed line has direction vector M**b**. This new direction does not depend on point A. Thus two different lines and that have the same direction will transform into two lines both having the direction , so they are parallel. The same argument can be applied to planes and beyond.

### 4. The Columns of the Matrix Reveal the Transformed Coordinate Frame

Take a generic affine transformation matrix for 2D,

The first two columns, and , are vectors (last component is 0). The last column is a point (last component is a 1).

Using the standard basis vectors , with origin , notice that **i** transforms to the vector . . Similarily for and .

### 5. Relative Ratios are Preserved

### 6. Area’s Under an Affine Transformation

Given an affine transformation as a matrix M,

### 7. Every Affine Transformation is Composed of Elementary Operations

Every affine transformation can be constructed by a composition of elementary operations (see below). That is,

For a 2D affine transformation M. In 3D,

## Rotations

Euler’s theorem: Any rotation (or sequence of rotations) about a point is equivalent to a single rotation about some coordinate axis through that point. Pages 221-223 of Hill give a detailed explanation of this, as well as the equations to go from one form to the other.

## W2V (Window to Viewport Mapping)

A simplified OpenGL pipeline applies the modelview matrix, projection matrix, clipping, then the viewport matrix. The viewport matrix is the window to viewport map.

The window coordinate system is somewhere on the projection plane. These coordinates need to be mapped to the viewport (the area on the screen)

## References

F.S. Hill, et al. (2006). Computer Graphics using OpenGL. Second Ed.

## COMP3421 – Lec 1 – Colour

## Colour

Pure spectral light, is where the light source has just one single wavelength. This forms monochromatic (or pure spectral) colours.

However mostly light is made up of light of multiple wavelengths so you end up with a distribution of wavelengths. You could describe colour by this frequency distribution of wavelengths. For example brown is not in the spectrum, but we can get brown from this distribution of different light wavelengths,

We could describe colour like this (as opposed to RGB) but human eyes perceive many different distributions (spectral density functions) as the same colour (that is they are indistinguishable when placed side by side). The total power of the light is known as its luminance which is given by the area under the entire spectrum.

The human eye has three cones (these detect light), the short, medium and long cones (we have two kinds of receptors cones and rods, rods are good for detecting in low light but they cannot detect colour or fine detail). The graph below shows how these three cones respond to different wavelengths.

So the colour we see is the result of our cones relative responses to RGB light. Because of this the human eye cannot distinguish some distributions that are different, to the eye they appear as the same color, hence you don’t need to recreate the exact spectrum to create the same sensation of colour. We can just describe the colour as a mixture of three colours.

There are three CIE standard primaries X, Y, Z. An XYZ colour has a one to one match to RGB colour. (See http://www.cs.rit.edu/~ncs/color/t_spectr.html for the formulae.)

Not all visible colours can be produced using the RGB system.

=====

Where S, P, N are spectral functions,

if S = P then N + S = N + P (ie. we can add a colour to both sides and if they were perceived the same before, they will be percieved the same after)

On one side you project on the other you project combinations of A, B and C to give

By experimentation it was shown that to match any pure spectral colour you needed the amounts of RGB shown,

=====

To detirmine the XYZ of a colour from its spectral distribution you need to use the following equations,

Where the , and functions are defined as,

## CIE Chromaticity Diagram

We can take a slice of the CIE space to get the CIE chromaticity diagram.

## RGB

(r, g, b) is the amount of red, green and blue primaries.

## CMY

CMY is a subtractive colour model (inks and paint works this way). (c,m,y) = (1,1,1) – (r,g,b).

But inks don’t always subtract well so printers usually use a black ink as well using CMYK.

## HSV

The HSV colour model is really good for allowing the user to select a colour as they choose the hue (colour), saturation (how rich the colour is) and value (how dark the colour is).

## Gamut

Gamut is the range of colours available which is represented as a triangle in the CIE Chromacity diagram. Different devices have different gamuts (for instance the printer and LCD monitor).

- Gamut Clipping – A shading in one image becomes just a solid colour in the other.
- Gamut Scaling – Shading looks the same but the size of the gamut is minimal.