0% found this document useful (0 votes)
26 views22 pages

CG - Unit - Iv

The document provides an overview of 3D transformations including translation, rotation, scaling, reflection, and shearing. It explains the mathematical equations and matrix representations for each transformation, as well as the steps required for general 3D rotations and fixed point scaling. Additionally, it discusses the viewing pipeline and the process of transforming world coordinates to viewing coordinates for 3D visualization.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views22 pages

CG - Unit - Iv

The document provides an overview of 3D transformations including translation, rotation, scaling, reflection, and shearing. It explains the mathematical equations and matrix representations for each transformation, as well as the steps required for general 3D rotations and fixed point scaling. Additionally, it discusses the viewing pipeline and the process of transforming world coordinates to viewing coordinates for 3D visualization.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

UNIT - IV

III YR – I SEM CSE

Prepared By: SUFIA ENAYAT, Asst.Professor


MALLAREDDY REDDY COLLAGE OF ENGINEERING
Maisammaguda, Secunderabad, Telangana.
3D Translation

Fig. 4.1: - 3D Translation.

• Similar to 2D translation, which used 3x3 matrices, 3D translation use 4X4 matrices (X, Y, Z, h).
• In 3D translation point (X, Y, Z) is to be translated by amount tx, ty and tz to location (X', Y', Z').
𝒙, = 𝒙 + 𝒕𝒙
𝒚, = 𝒚 + 𝒕𝒚
𝒛, = 𝒛 + 𝒕𝒛
• Let’s see matrix equation

• Example : - Translate the given point P (10,10,10) into 3D space with translation factor T (10,20,5).
[

Final coordinate after translation is P, (20, 30, 15).

Rotation
• For 3D rotation we need to pick an axis to rotate about.
• The most common choices are the X-axis, the Y-axis, and the Z-axis

2
Coordinate-Axes Rotations

Y Y Y

X X X

Z Z Z

(a) (b) (c)

Fig. 4.2: - 3D Rotations.

Z-Axis Rotation
• Two dimension rotation equations can be easily convert into 3D Z-axis rotation equations.
• Rotation about z axis we leave z coordinate unchanged.
𝒙, = 𝒙 𝐜𝐨𝐬 𝜽 − 𝒚 𝐬𝐢𝐧 𝜽
𝒚, = 𝒙 𝐬𝐢𝐧 𝜽 + 𝒚 𝐜𝐨𝐬 𝜽
𝒛, = 𝒛
Where Parameter 𝜽 specify rotation angle.
• Matrix equation is written as:

X- Axis Rotation
• Transformation equation for x-axis is obtain from equation of z-axis rotation by replacing cyclically as
shown here
𝒙→𝒚→𝒛→𝒙
• Rotation about x axis we leave x coordinate unchanged.
𝒚, = 𝒚 𝐜𝐨𝐬 𝜽 − 𝒛 𝐬𝐢𝐧 𝜽
𝒛, = 𝒚 𝐬𝐢𝐧 𝜽 + 𝒛 𝐜𝐨𝐬 𝜽
𝒙, = 𝒙
Where Parameter 𝜽 specify rotation angle.
• Matrix equation is written as:

Y- Axis Rotation
Transformation equation for y-axis is obtain from equation of x-axis rotation by replacing cyclically as

3
shown here

𝒙→𝒚→𝒛→𝒙
• Rotation about y axis we leave y coordinate unchanged.
𝒛, = 𝒛 𝐜𝐨𝐬 𝜽 − 𝒙 𝐬𝐢𝐧 𝜽
𝒙, = 𝒛 𝐬𝐢𝐧 𝜽 + 𝒙 𝐜𝐨𝐬 𝜽
𝒚, = 𝒚
Where Parameter 𝜽 specify rotation angle.
• Matrix equation is written as:

Example: - Rotate the point P(5,5,5) 90o about Z axis.

Final coordinate after rotation is P, (-5, 5, 5).

General 3D Rotations when rotation axis is parallel to one of the standard axis
• Three steps require to complete such rotation
1. Translate the object so that the rotation axis coincides with the parallel coordinate axis.
2. Perform the specified rotation about that axis.
3. Translate the object so that the rotation axis is moved back to its original position.
• This can be represented in equation form as:
𝑷′ = 𝑻−𝟏 ∙ 𝑹(𝜽) ∙ 𝑻 ∙ 𝑷

General 3D Rotations when rotation axis is inclined in arbitrary direction


• When object is to be rotated about an axis that is not parallel to one of the coordinate axes, we need
rotations to align the axis with a selected coordinate axis and to bring the axis back to its original
orientation.
• Five steps require to complete such rotation.
1. Translate the object so that the rotation axis passes through the coordinate origin.

4
2. Rotate the object so that the axis of rotation coincides with one of the coordinate axes.
3. Perform the specified rotation about that coordinate axis.
4. Apply inverse rotations to bring the rotation axis back to its original orientation.
5. Apply the inverse translation to bring the rotation axis back to its original position.
• We can transform rotation axis onto any of the three coordinate axes. The Z-axis is a reasonable choice.
• We are given line in the form of two end points P1 (x1,y1,z1), and P2 (x2,y2,z2).
• We will see procedure step by step.
1) Translate the object so that the rotation axis passes through the coordinate origin.

Y
P2

P1

Fig. 4.3: - Translation of vector V.


• For translation of step one we will bring first end point at origin and transformation matrix for the same is
as below

2) Rotate the object so that the axis of rotation coincides with one of the coordinate axes.
• This task can be completed by two rotations first rotation about x-axis and second rotation about y-axis.
• But here we do not know rotation angle so we will use dot product and vector product.
• Lets write rotation axis in vector form.
𝑽 = 𝑷𝟐 − 𝑷𝟏 = (𝒙𝟐 − 𝒙𝟏, 𝒚𝟐 − 𝒚𝟏, 𝒛𝟐 − 𝒛𝟏)
• Unit vector along rotation axis is obtained by dividing vector by its magnitude.

Fig. 4.4: - Projection of u on YZ-Plane.

5
• Now we need cosine and sin value of angle between unit vector ‘u’ and XZ plane and for that we will
take projection of u on YZ-plane say ‘u’’ and then find dot product and cross product of ‘u’’ and ‘uz’ .
• Coordinate of ‘u’’ is (0,b,c) as we will take projection on YZ-plane x value is zero.
𝒖′ ∙ 𝒖𝒛 = |𝒖′||𝒖𝒛| 𝐜𝐨𝐬 𝑎

• Now we have 𝐬𝐢𝐧 𝑎 and 𝐜𝐨𝐬 𝑎 so we will write matrix for rotation about X-axis.

• 𝒙 2 2
After performing above rotation ‘u’ will rotated into ‘u’’’ in XZ-plane with coordinates (a, 0, √(b +c )). As we
know rotation about x axis will leave x coordinate unchanged, ‘u’’’ is in XZ=plane so y coordinate is zero,
and z component is same as magnitude of ‘u’’.
• Now rotate ‘u’’’ about Y-axis so that it coincides with Z-axis.

X
uz β u’’

Z
Fig. 4.5: - Rotation of u about X-axis.
• For that we repeat above procedure between ‘u’’’ and ‘uz’ to find matrix for rotation about Y-axis.

6
(𝟏) 𝐬𝐢𝐧 𝖰 = − 𝒂
𝐬𝐢𝐧 𝖰 = − 𝒂
• Now we have 𝐬𝐢𝐧 𝖰 and 𝐜𝐨𝐬 𝖰 so we will write matrix for rotation about Y-axis.

• Now by combining both rotation we can coincides rotation axis with Z-axis
3) Perform the specified rotation about that coordinate axis.
• As we know we align rotation axis with Z axis so now matrix for rotation about z axis

4) Apply inverse rotations to bring the rotation axis back to its original orientation.
• This step is inverse of step number 2.
5) Apply the inverse translation to bring the rotation axis back to its original position.
6) This step is inverse of step number 1.

So finally sequence of transformation for general 3D rotation is

𝑷′ = 𝑻−𝟏 ∙ 𝑹𝒙−𝟏(𝑎) ∙ 𝑹𝒚−𝟏(𝖰) ∙ 𝑹𝒛(𝜽) ∙ 𝑹𝒚(𝖰) ∙ 𝑹𝒙(𝑎) ∙ 𝑻 ∙ 𝑷

Scaling
• It is used to resize the object in 3D space.
• We can apply uniform as well as non uniform scaling by selecting proper scaling factor.
• Scaling in 3D is similar to scaling in 2D. Only one extra coordinate need to consider into it.

7
Coordinate Axes Scaling

Fig. 4.6: - 3D Scaling.


• Simple coordinate axis scaling can be performed as below.
𝑷′ = 𝑺 ∙ 𝑷

• Example: - Scale the line AB with coordinates (10,20,10) and (20,30,30) respectively with scale factor
S(3,2,4).

Final coordinates after scaling are A, (30, 40, 40) and B’ (60, 60, 120).

Fixed Point Scaling

Fig. 4.7: - 3D Fixed point scaling.

8
• Fixed point scaling is used when we require scaling of object but particular point must be at its original
position.
• Fixed point scaling matrix can be obtained in three step procedure.
1. Translate the fixed point to the origin.
2. Scale the object relative to the coordinate origin using coordinate axes scaling.
3. Translate the fixed point back to its original position.
• Let’s see its equation.

Other Transformations

Reflections
• Reflection means mirror image produced when mirror is placed at require position.
• When mirror is placed in XY-plane we obtain coordinates of image by just changing the sign of z coordinate.
• Transformation matrix for reflection about XY-plane is given below.

• Similarly Transformation matrix for reflection about YZ-plane is.

• Similarly Transformation matrix for reflection about XZ-plane is.

Shears
• Shearing transformation can be used to modify object shapes.
• They are also useful in 3D viewing for obtaining general projection transformations.
• Here we use shear parameter ‘a’ and ‘b’
• Shear matrix for Z-axis is given below

9
• Similarly Shear matrix for X-axis is.

• Similarly Shear matrix for X-axis is.

Viewing Pipeline

Modeling Modeling World Viewing Viewing


Coordinates Transformation Coordinates Transformation Coordinates

Projection Projection Workstation Device


Transformation Coordinates Transformation Coordinates

Fig. 4.8: - General 3D viewing pipeline.


• Steps involved in 3D pipeline are similar to the process of taking a photograph.
• As shown in figure that initially we have modeling coordinate of any object which we want to display on
the screen.
• By applying modeling transformation we convert modeling coordinates to world coordinates which gives
which part or portion is to be display.
• Then by applying viewing transformation we obtain the viewing coordinate which is fitted in viewing
coordinate reference frame.
• Then in case of three dimensional objects we have three dimensions coordinate but we need to display
that object on two dimensional screens so we apply projection transformation on it which gives projection
coordinate.
• Finally projection coordinate is converted into device coordinate by applying workstation transformation
which gives coordinates which is specific to particular device.

Viewing Co-ordinates.
• Generating a view of an object is similar to photographing the object.
• We can take photograph from any side with any angle & orientation of camera.

10
• Similarly we can specify viewing coordinate in ordinary direction.

Fig. 4.9: -A right handed viewing coordinate system, with axes Xv, Yv, and Zv, relative to a world-
coordinate scene.

Specifying the view plan


• We decide view for a scene by first establishing viewing coordinate system, also referred as view reference
coordinate system.
• Then projection plane is setup in perpendicular direction to Zv axis.
• Then projections positions in the scene are transferred to viewing coordinate then viewing coordinate are
projected onto the view plane.
• The origin of our viewing coordinate system is called view reference point.
• View reference point is often chosen to be close to or on the surface as same object scene. We can also
choose other point also.
• Next we select positive direction for the viewing Zv axis and the orientation of the view plane by specifying
the view plane normal vector N.
• Finally we choose the up direction for the view by specifying a vector V called the view up vector. Which
specify orientation of camera.
• View up vector is generally selected perpendicular to normal vector but we can select any angle between V
& N.
• By fixing view reference point and changing direction of normal vector N we get different views of same
object this is illustrated by figure below.

Fig. 4.10: -Viewing scene from different direction with a fixed view-reference point.

Transformation from world to viewing coordinates


• Before taking projection of view plane object description is need to transfer from world to viewing

11
coordinate.
• It is same as transformation that superimposes viewing coordinate system to world coordinate system.
• It requires following basic transformation.
• 1) Translate view reference point to the origin of the world coordinate system.
• 2) Apply rotation to align

Fig. 4.11: - Aligning a viewing system with the world-coordinate axes using a sequence of translate-rotate
transformations.
• As shown in figure the steps of transformation
• Consider view reference point in world coordinate system is at position (𝑥0, 𝑦0, 𝑧0)than for align view
reference point to world origin we perform translation with matrix:

• Now we require rotation sequence up-to three coordinate axis rotations depending upon direction we
choose for N.
• In general case N is at arbitrary direction then we can align it with word coordinate axes by rotation
sequence 𝑅𝑧 ∙ 𝑅𝑦 ∙ 𝑅𝑥.
• Another method for generating the rotation transformation matrix is to calculate unit uvn vectors and from
the composite rotation matrix directly.
• Here
𝑁
𝑛= = (𝑛1, 𝑛2 , 𝑛3)
|𝑁|
𝑉×𝑁
𝑢= = (𝑢1, 𝑢2 , 𝑢3)
|𝑉 × 𝑁|
𝑣 = 𝑛 × 𝑢 = (𝑣1, 𝑣2, 𝑣3)
• This method also automatically adjusts the direction for u so that v is perpendicular to n.
• Than composite rotation matrix for the viewing transformation is then:

• This aligns u to Xw axis, v to Yw axis and n to Zw axis.


• Finally composite matrix for world to viewing coordinate transformation is given by:
• 𝑀𝑤𝑐,𝑣𝑐 = 𝑅 ∙ 𝑇
• This transformation is applied to object’s coordinate to transfer them to the viewing reference frame.

12
Projections
• Once world-coordinate descriptions of the objects in a scene are converted to viewing coordinates, we can
project the three-dimensional objects onto the two-dimensional view plane.
• Process of converting three-dimensional coordinates into two-dimensional scene is known as projection.
• There are two projection methods namely.
1. Parallel Projection.
2. Perspective Projection.
• Let’s discuss each one.

Parallel Projections
View
Plane
P1
P1’

P2
P2’

Fig. 4.12: - Parallel projection.

• In a parallel projection, coordinate positions are transformed to the view plane along parallel lines, as
shown in the, example of above Figure.
• We can specify a parallel projection with a projection vector that defines the direction for the projection
lines.
• It is further divide into two types.
1. Orthographic parallel projection.
2. Oblique parallel projection.

Orthographic parallel projection

View Plane

Projection Line

Fig. 4.13: - Orthographic parallel projection.


• When the projection lines are perpendicular to the view plane, we have an orthographic parallel
projection.
• Orthographic projections are most often used to produce the front, side, and top views of an object, as
shown in Fig.

13
Fig. 4.14: - Orthographic parallel projection.
• Engineering and architectural drawings commonly use orthographic projections, because lengths and
angles are accurately depicted and can be measure from the drawings.
• We can also form orthographic projections that display more than one face of an object. Such view are
called axonometric orthographic projections. Very good example of it is Isometric projection.
• Transformation equations for an orthographic parallel projection are straight forward.
• If the view plane is placed at position zvp along the zv axis, then any point (x, y, z) in viewing coordinates is
transformed to projection coordinates as
𝒙𝒑 = 𝒙, 𝒚𝒑 =𝒚

(X,Y,Z) Yv

(X,Y)
Xv

Zv

Fig. 4.15: - Orthographic parallel projection.


• Where the original z-coordinate value is preserved for the depth information needed in depth cueing and
visible-surface determination procedures.

Oblique parallel projection.

View Plane

Projection Line

14
Fig. 4.16: - Oblique parallel projection.
• An oblique projection is obtained by projecting points along parallel lines that are not perpendicular to the
projection plane.
• Coordinate of oblique parallel projection can be obtained as below.
Yv

(Xp, Yp)
(X,Y,Z)
αL
Φ
Xv
(X,Y)

Zv

Fig. 4.17: - Oblique parallel projection.


• As shown in the figure (X,Y,Z) is a point of which we are taking oblique projection (Xp,Yp) on the view plane
and point (X,Y) on view plane is orthographic projection of (X,Y,Z).
• Now from figure using trigonometric rules we can write

𝒙𝒑 = 𝒙 + 𝑳 𝐜𝐨𝐬 ∅
𝒚𝒑 = 𝒚 + 𝑳 𝐬𝐢𝐧 ∅
• Length L depends on the angle α and the z coordinate of the point to be projected:

• Now put the value of L in projection equation.


𝒙𝒑 = 𝒙 + 𝒁𝑳𝟏 𝐜𝐨𝐬 ∅
𝒚𝒑 = 𝒚 + 𝒁𝑳𝟏 𝐬𝐢𝐧 ∅
• Now we will write transformation matrix for this equation.

• This equation can be used for any parallel projection. For orthographic projection L1=0 and so whole term
which is multiply with z component is zero.
• When value of 𝐭𝐚𝐧 𝑎 = 𝟏 projection is known as Cavalier projection.
• When value of 𝐭𝐚𝐧 𝑎 = 𝟐 projection is known as Cabinet projection.

15
Perspective Projection

Fig. 4.18: - Perspective projection.


• In perspective projection object positions are transformed to the view plane along lines that converge to a
point called the projection reference point (or center of projection or vanishing point).

P=(x,y,z)

(xp,yp,zvp)

zvp zprp zv
View
Plane

Fig. 4.19: - Perspective projection.


Suppose we set the projection reference point at position zprp along the zv axis, and we place the view plane at zvp
as shown in Figure above. We can write equations describing coordinate positions along this perspective
projection line in parametric form as
𝒙′ = 𝒙 −𝒙𝒖
𝒚′ = 𝒚 −𝒚𝒖
𝒛′ = 𝒛 − (𝒛 − 𝒛𝒑𝒓𝒑)𝒖
• Here parameter u takes the value from 0 to 1, which is depends on the position of object, view plane, and
projection reference point.
• For obtaining value of u we will put z’=zvp and solve equation ofz’.

• Now substituting value of u in equation of x’ and y’ we will obtain.

• Using three dimensional homogeneous-coordinate representations, we can write the perspective


projection transformation matrix form as.

16
• In this representation, the homogeneous factor is.

• There are number of special cases for the perspective transformation equations.
• If view plane is taken to be uv plane, then 𝒛𝒗𝒑 = 𝟎 and the projection coordinates are.

• If we take projection reference point at origin than 𝒛𝒑𝒓𝒑 = 𝟎 and the projection coordinates are.

• The vanishing point for any set of lines that are parallel to one of the principal axes of an object is referred
to as a principal vanishing point
• We control the number of principal vanishing points (one, two, or three) with the orientation of the
projection plane, and perspective projections are accordingly classified as one-point, two-point, or three-
point projections.
• The number of principal vanishing points in a projection is determined by the number of principal axes
intersecting the view plane.

17
View Volumes and General Projection Transformations

Parallelpiped
View Volume Frustum
View
Zv Volume

Window

Zv
Back Front
Window
Plane Plane
Projection
Parallel Projection Back Reference
Front
(a) Plane Point
Plane

Perspective Projection
(b)

Fig. 4.20: - View volume of parallel and perspective projection.


• Based on view window we can generate different image of the same scene.
• Volume which is appears on the display is known as view volume.
• Given the specification of the view window, we can set up a view volume using the window boundaries.
• Only those objects within the view volume will appear in the generated display on an output device; all
others are clipped from the display.
• The size of the view volume depends on the size of the window, while the shape of the view volume
depends on the type of projection to be used to generate the display.
• A finite view volume is obtained by limiting the extent of the volume in the zv direction.
• This is done by specifying positions for one or two additional boundary planes. These zv-boundary planes
are referred to as the front plane and back plane, or the near plane and the far plane, of the viewing
volume.
• Orthographic parallel projections are not affected by view-plane positioning, because the projection lines
are perpendicular to the view plane regardless of its location.
• Oblique projections may be affected by view-plane positioning, depending on how the projection direction
is to be specified.

General Parallel-Projection Transformation


• Here we will obtain transformation matrix for parallel projection which is applicable to both orthographic
as well as oblique projection.

N Zv
Window

View Vp
Volume 18
Fig. 4.21: - General parallel projection.
• As shown on figure parallel projection is specified with a projection vector from the projection reference
point to the view window.
• Now we will apply shear transformation so that view volume will convert into regular parallelepiped and
projection vector will become parallel to normal vector N.

Window N Zv

View V’p
Volume

Fig. 4.22: - Shear operation in General parallel projection.


• Let’s consider projection vector 𝑽𝒑 = (𝒑𝒙, 𝒑𝒚, 𝒑𝒛).
• We need to determine the elements of a shear matrix that will align the projection vector 𝑽𝒑 with the view
plane normal vector N. This transformation can be expressed as

where 𝑴𝒑𝒂𝒓𝒂𝒍𝒍𝒆𝒍 is equivalent to the parallel projection matrix and represents a z-axis shear of the form

Now from above equation we can write

• From matrix we can write.

Thus, we have the general parallel-projection matrix in terms of the elements of the projection vector as

19
• For an orthographic parallel projection, px = py = 0, and is the identity matrix.

General Perspective-Projection Transformations


• The projection reference point can be located at any position in the viewing system, except on the view
plane or between the front and back clipping planes.

Fig. 4.23: - General perspective projection.


• We can obtain the general perspective-projection transformation with the following two operations:
1. Shear the view volume so that the center line of the frustum is perpendicular to the view plane.
2. Scale the view volume with a scaling factor that depends on 1/z .
• A shear operation to align a general perspective view volume with the projection window is shown in
Figure.

Fig. 4.24: - Shear and scaling operation in general perspective projection.

20
With the projection reference point at a general position (Xprp, Yprp, Zprp) the transformation involves a combination z-
axis shear and a translation:

• Where the shear parameters are

• Points within the view volume are transformed by this operation as

• After shear we apply scaling operation.

• Homogeneous matrix for this transformation is:

• Therefore the general perspective-projection transformation is obtained by equation:


𝑴𝒑𝒆𝒓𝒔𝒑𝒆𝒄𝒕𝒊𝒗𝒆 = 𝑴𝒔𝒄𝒂𝒍𝒆 ∙ 𝑴𝒔𝒉𝒆𝒂r

21
22

You might also like