15 3D Viewing(Viewing Transformations)

T. Raghuveera

epgp books

 

 

Objectives:

  1. Understand how a viewing coordinate system is set up
  2. Understand the theory behind projection transformations, including, parallel and perspective

 

Discussion:

 

Let’s understand how a viewing coordinate system is setup in 3D. Setting up a viewing coordinate system is the first step in 3D viewing and this is similar to setting up a standard coordinate system (3 mutually perpendicular directions) at a given viewing position.The name viewing coordinate system is because; it is the reference position from where we view the objects in the world. Also it is important to remember the convention of RHS, that we always view the world along the negative z-axis. Once the VCS is set up, the next step is to convert world coordinates to viewing coordinates through viewing transformation. Before we proceed any further, it is important to understand the 3D viewing pipeline, which is similar to that of the 2D viewing pipeline (refer to Module 8).

 

The sequence of steps in the 3D viewing pipeline is

 

 

    MT– Modeling Transformation (converts Model coordinates to World coordinates)

VT– Viewing Transformation (World coordinates to Viewing coordinates) PT – Projection Transformation (Converts Viewing coordinates to Projection Coordinates)

CT – Clipping Transformation (Converts Projection coordinates to clipping coordinates)

VT – Viewport Transformation (Converts clipping coordinates to Normalized coordinates)

DT – Device Transformation (Converts Normalized coordinates to Device Coordinates)

 

Imagine, we have to create 3D world with a set of objects of choice. The first step is to create an object in the 3D world. For this we need to identify a position in the 3D world, determine the dimensions, orientation of the object. We know from earlier discussions, that every object is initially created and identified with respect to its local / model coordinate system (a reference system, whose origin is at the centre of the object and the three mutually perpendicular directions determine the dimensions and orientation of the object in the 3D world).

 

The next step is to similarly create other objects of interest. Once the objects of interest are created, it’s time to set up the viewing coordinate system (VCS), where we decide what is to be viewed. Once VCS is set up, we decide about the suitable projection transformation (parallel or perspective), which involves, deciding the shape of the view volume. The shape of the view volume depends on the type of projection transformation chosen.View volume is a volume of space in the 3D world. Once the shape is decided, the next step is to clip the contents of the world with respect to the view volume boundaries. This step is performed in Clipping Transformation, where, whichever objects that lie within the volume are selected for display. In 2D viewing, clipping is performed against a rectangular clip window, while in 3Dviewing, clipping is performed against a view volume. The penultimate step involves, converting clipped coordinates to normalized coordinatesthroughviewport transformation. And finally the Device Transformation converts normalized coordinates to device coordinates.

 

The above discussion can be easily understood by taking the analogy of a camera.We first choose a vantage point (position), then align our camera with the objects of interest(orientation), then decide what part of the world is to be captured (projection transformation), and select only that part of the world that falls within the rectangular region of the cameras view finder (clipping). Finally what is of interest is only captured on the film of the camera.

 

Viewing Transformation:

 

This is performed to convert world coordinates (WC) to viewing coordinates (VC). To perform this transformation, we need to set up the viewing coordinate system (VCS). Setting up a VCS involves, choosing a position, direction and orientationfor a new 3D coordinate system, to look at the 3D world.

 

 

As can be seen from the figures above, a viewing coordinate system is derived from the world coordinate system, where P0(x0, y0, z0) happens to be the origin of the VCS and Xv, Yv, Zv are the 3 mutually perpendicular directions of the VCS.A view plane is generally the XY plane of the viewing coordinate system and meant for taking snaps of the world. In camera analogy a viewplane is similar to that of a film in a camera.

 

To set up a VCS, first choose a position in the 3D world and call it the origin of the VCS. The next step is to identify 3 mutually perpendicular directions. It is enough if we identify two mutually perpendicular directions; the third direction is simply obtained by taking vector cross product of two vectors in the plane of the two already computed directions.At first let’s focus on the Z-direction (Zv)of the VCS. The convention (as used in OpenGL) is that, select a look-at point (a look-at point is a position in the 3D world where we are looking at) in the 3D world, connect the origin of the VCS with the look-at point, and the direction thus obtained is the Zvdirection of the VCS. The direction from the look-at point to the origin of the VCS is considered the +ve Zv direction as shown in the figure below.

 

 

i) Choose any position in the WCS and call it as viewing origin P0(x0,y0,z0).

ii)Specify the +ve Zv direction of the VCS by choosing a look-at point in the world. The direction from look at point to the viewing origin is the direction of the normal vectorN’ to the view plane as well as the +ve Zv direction. Thus Zv is established.

iii)  Choose any upward direction for viewing Y-axis (Yv).(For convenience, this direction may be chosen as the direction of the world Y-axis and at a later point of time we shall make necessary corrections for it.).Choose the unit vector direction (0,1,0), which is the vector along the world Y-axis, and then project the direction onto a plane perpendicular to N direction.This direction is called the View-Up vector denoted as V, which is the Yv direction of the VCS.

iv)  The direction for Xv axis can be chosen by computing vector U perpendicular to both N and

 

V.

N–  View plane Normal vector (along Zv axis)

V–  View up vector (along Yvaxis)

 U              –  Perpendicular to both N and V (along Xv axis)

 

The unit vectors along U, V and N are considered as u, v, nrespectively, and then the VCS is also referred to as uvn system.

 

Conversion from world to viewing coordinates:

 

Now that we have set up the VCS, we need to perform the conversion from WC to VC. This is because, when we observe the same world from different viewing position (VCS), the objects in the world now assume different dimensions and properties. This transformation is similar to the transformation between coordinate systems in 2D. Now follow the steps as mentioned below.

 

i) Translation:

Translate the view reference point to the origin of the WC system as shown below

 

ii) Rotation:

Apply rotations to align the Xv, Yv, and Zv axes with the corresponding world axes.

  • Rotate around the world Xw axis to bring Zv into the XwZw plane
  • Rotate around the world Yw axis to align the Zw and Zv axis
  • Final rotation is about the Zw axis to align the Yw and Yv axis

 

The aim of this rotation step is to align the VCS with WCS. This can be represented in notation as R=RzRyRx

 

The composite matrix for rotation is MWC->VC = R.T, where the Rotation R and Translation matrix T are as given below.

 

 

Projection Transformation:

 

Projection transformation step in 3D should not be misunderstood as conversion from 3D to 2D. The step is meant to determine the correct view volume, depending the type of projection we choose. There are two basic classes of planar projection, Parallel and Perspective. The viewing volume determines

 

•  How an object is projected onto the screen (i.e.,orthographic projection or perspective projection)

•  Which objects or portions of objects are clipped out of the final image.

 

Projection Transformations are classified as shown below.

 

The classification diagram shows that perspective transformations are classified as one-point, two-point and three-point, while parallel transformations have a detailed classification tree.

 

In parallel projections, an object is projected on to an imaginary 2D view plane or projection plane, along lines that are parallel to each other. These projections are useful for getting various viewslike front, side, top.

 

Perspective Projections:

 

In perspective projection, an object is projected on to an imaginary 2D view plane or projection plane, along lines that converge at a point called ‘center of projection’ (COP) or Projection Referencepoint or eye. As can be noticed, the size of the object varies with distance from the COP.Projections of distant objects are smaller than the projections of objects of the same size that are closer to the projection plane.

As we humans see the world as perspective, these projections give human like realistic views of the world. Now let’s compare both of these projections.

 

Summary:

  • Understood the setting up of the viewing coordinate system
  • Looked at the introduction of Projection transformations.
you can view video on 3D Viewing(Viewing Transformations)