Coordinate transformations

 

Operations over vectors (matrix form)

            Scalar (dot) product

            Vector (cross) product

Transformation of coordinates

Coordinate systems

Translation

Rotation

Scaling

Homogeneous coordinates

Composition and inversion of transformations

Projection transformations

Parallel projection

Perspective projection

 

            Operations over vectors  (matrix form)                              

 

Vector is defined as a single column matrix

 

a =

 

            Scalar (dot) product is defined as

 

a*b  = a1 b1 + a2 b2 + a3 b3,

 

or, in the matrix form,

                                               

a*b = aTb

 

            Vector (cross) product

 

is a vector with components

 

a x b =

 

or in the vector form,

 

=Ab

 

 

            Coordinate systems

 

            Variety of coordinate systems.

            World coordinate system.

            Display coordinate system (pixelated).

            Object coordinate system : object definition is not changed with respect to its own coordinate system.

 

Many transformations are best specified in a relative fashion.

 

World->road->car->front left wheel – scene graph. Going down the scene graph is postmultiplication of the current transformation

matrix.

.

              

Each coordinate is represented by the three x,y,z values.

 

r =

 

Right-handed and left-handed coordinate systems.

 

 

We shall denote new coordinates after transformation as

 

 

 

            Translation

 

            If the object is translated without rotation, the relationship between the new and old point coordinate is the following :

 

 

 or

 

= +

            Translation of coordinate axes is equivalent to translation of object in opposite direction.

            Rotation

   First, let’s consider rotation in two dimensions in plane x-y by angle . z-coordinate does not change.

Using polar coordinates in plane Oxy, we see that polar coordinates of some point () in the result of rotation about the origin become (). As  and ,

 

            or

           

 

            In the matrix form

 

           

 

            If coordinate axes are rotated, the object is rotated by angle - and

 

           

 

            A = B T

 

            Rotation in 3 dimensions about arbitrary vector U by angle   is defined by the matrix

 

 

            Scaling

 

 

where  - scaling coefficient for x-coordinate,  - for y-coordinate,  - for z-coordinate.

 

            Homogeneous coordinates

 

            Rotation, scaling can be defined by the matrix multiply in the form

 

            r’ = A r

 

            Translation cannot be represented in this way.

To include translations into matrix transformations, each vector is represented in homogeneous coordinates

 

            R =

 

            Definition of homogeneous coordinates :

 

            P = wR,

 

            where w is homogenous parameter, varying from point to point. Components of vector P (xw,yw,zw,w) are homogeneous coordinates of point (x,y,z). Cartesian coordinates x,y,z are obtained from homogeneous coordinates by division

 

            x = P1/P4

 

            y = P2/P4

 

            z = P3/P4

 

            So, the representation of point is not unique, like equation of line ax+by+c=0 has no unique coefficients, only relations between coefficients are meaningful.

             

            For translation, honogeneous parameter is constant and equals to 1.

And all transformation matrices for rotation and scaling get the 4x4 dimensions :

               

            and for translation looks like this :

               

Composition and inversion of transformations

A series of transformations can be accumulated into a single transformation matrix.

Suppose our object is defined as follows and we wish to place the object in our scene like this:

 

            This can be accomplished in several ways, one of which is:

            1. rotate object by -90 clockwise

            the rotation matrix being

                       

                 =

 

            2. translate object by vector (5,3,0)

            the translation matrix being

                 

            The composition is

 

Pworld  =   Plocal  =  Plocal

 


 Pworld = M Plocal,

Plocal = M-1 Pworld

 

M =    M1 M2 M3 M4  ... Mn

pre                       post

 

 

Projection transformations

Mapping 3D object onto plane (screen). Number of dimensions is decreased by one! Problems with the back transformation.
 

Parallel projection

        

Perspective projection

·         produces foreshortening

·         non-linear

 

         A visual effect of non-linearity, distorted contours of windows :

 

 

         The explanation lies in non-liear mapping of textures onto the screen:

 

Let's use the following example to construct a matrix that performs a perspective transformation:

 

From similar triangles, we can see that  y'/d = y/z
Thus, y' = yd/z , similarly, x' = xd/z , and z’ = d.

 

In homogeneous coordinates, in matrix form,

 

 =

 

               x’w’ = x

 

               homogeneous parameter w’ = z/d.