Computer Graphics Modules Wise Questions & Notes - Aeraxia - in
Computer Graphics Modules Wise Questions & Notes - Aeraxia - in
1.Computer Art:
Using computer graphics we can create fine and commercial art
which include animation packages, paint packages. These
packages provide facilities for designing object shapes and
specifying object motion.Cartoon drawing, paintings, logo design
can also be done.
3.Presentation Graphics:
For the preparation of reports or summarising the
1) financial Report
2) statistical Report
3) mathematical Report
4) scientific Report
4.Entertainment:
Computer graphics finds a major part of its utility in the movie
industry and game industry. Used for creating motion pictures ,
music video, television shows, cartoon animation films. In the
game industry where focus and interactivity are the key players,
computer graphics helps in providing such features in the
efficient way.
5.Education:
Computer generated models are extremely useful for teaching
huge number of concepts and fundamentals in an easy to
understand and learn manner. Using computer graphics many
educational models can be created through which more interest
can be generated among the students regarding the subject.
6.Training:
Specialised system for training like simulators can be used for
training the candidates in a way that can be grasped in a short
span of time with better understanding. Creation of training
modules using computer graphics is simple and very useful.
7.Visualisation:
Today the need of visualise things have increased drastically, the
need of visualisation can be seen in many advance technologies ,
data visualisation helps in finding insights of the data , to check
and study the behaviour of processes around us we need
appropriate visualisation which can be achieved through proper
usage of computer graphics
8.Image Processing:
Various kinds of photographs or images require editing in order
to be used in different places. Processing of existing images into
refined ones for better interpretation is one of the many
applications of computer graphics.
9.Machine Drawing:
Computer graphics is very frequently used for designing,
modifying and creation of various parts of machine and the
whole machine itself, the main reason behind using computer
graphics for this purpose is the precision and clarity we get from
such drawing is ultimate and extremely desired for the safe
manufacturing of machine using these drawings.
Advantages:
1. A CRT has the electron beam directed only to the parts of the
screen where an image is to be drawn.
2. Produce smooth line drawings.
3. High Resolution
Disadvantages:
1. Interlaced Scanning
2. Non-Interlaced Scanning
Advantages:
1. Realistic image
2. Million Different colors to be generated
3. Shadow Scenes are possible.
Disadvantages:
1. Point
2. Line
3. Sector
4. Arc
5. Ellipse
6. Rectangle
7. Polygon
8. Characters
9. Filled Regions
Pixel or Pel:
The closer the dots or pixels are, the better will be the quality of
picture. Closer the dots are, crisper will be the picture. Picture will
not appear jagged and unclear if pixels are closely spaced. So the
quality of the picture is directly proportional to the density of
pixels on the screen.
P (5, 5) used to represent a pixel in the 5th row and the 5th
column. Each pixel has some intensity value which is represented
in memory of computer called a frame buffer. Frame Buffer is
also called a refresh buffer. This memory is a storage area for
storing pixels values using which pictures are displayed. It is also
called as digital memory. Inside the buffer, image is stored as a
pattern of binary digits either 0 or 1. So there is an array of 0 or 1
used to represent the picture. In black and white monitors, black
pixels are represented using 1's and white pixels are represented
using 0's. In case of systems having one bit per pixel frame buffer
is called a bitmap. In systems with multiple bits per pixel it is
called a pixmap.
Q7) Scan Conversion Definition
1. Point
2. Line
3. Sector
4. Arc
5. Ellipse
6. Rectangle
7. Polygon
8. Characters
9. Filled Regions
Imagine a picture you drew with perfect lines and curves. That's
a vector image. Rasterization takes that vector image and
translates it into a grid of colored squares – the pixels. The more
pixels used, the closer the rasterized image will resemble the
original vector image.
Q10) Resolution:
Resolution refers to the number of pixels packed into a digital
image. Think of it as the density of the tiny squares (pixels) that
make up the image. The more pixels you have, the higher the
resolution and the sharper the image will be.
Screen Resolution:
• What it is: Screen resolution refers to the number of pixels
that make up a display, like a computer monitor, phone
screen, or TV. It's expressed in width x height format (e.g.,
1920 x 1080 pixels).
• Impact: Screen resolution determines how much detail and
sharpness you see on your screen. Higher resolution means
more pixels, leading to a sharper and crisper image.
Image Resolution:
• What it is: Image resolution refers to the number of pixels
that make up a digital image (e.g., a photograph, graphic, or
screenshot). It's also expressed in width x height format.
• Impact: Image resolution determines the level of detail and
clarity of the image itself. Higher resolution images contain
more pixels and can capture finer details.
Analogy to understand the difference:
Examples:
• Scenario: You have a high-resolution image (3840 x 2160
pixels) displayed on a low-resolution screen (1024 x 768
pixels).
• Result: The image will be shrunk to fit the screen. You
might see some loss of detail because the screen doesn't
have enough pixels to display the full resolution of the
image.
• Scenario: You have a low-resolution image (640 x 480
pixels) displayed on a high-resolution screen (1920 x 1080
pixels).
• Result: The image will be blown up to fit the screen. This
can result in a pixelated or blurry image because the
software has to stretch the limited number of pixels to fill
the larger space.
In essence:
• Screen resolution is a property of the display device.
• Image resolution is a property of the image file itself.
Step-02:
Problem-01:
Calculate the points between the starting coordinates (9, 18) and ending
coordinates (14, 22).
Solution-
Given-
• Starting coordinates = (X0, Y0) = (9, 18)
Step-01:
Step-03:
Thus,
• Pk+1 = Pk + 2ΔY – 2ΔX = 3 + (2 x 4) – (2 x 5) = 1
• Xk+1 = Xk + 1 = 9 + 1 = 10
• Yk+1 = Yk + 1 = 18 + 1 = 19
Similarly, Step-03 is executed until the end point is reached or number
of iterations equals to 4 times.
(Number of iterations = ΔX – 1 = 5 – 1 = 4)
Step-01:
Calculate ΔX and ΔY from the given input.
• ΔX = Xn – X0 = 30 – 20 = 10
• ΔY =Yn – Y0 = 18 – 10 = 8
Step-02:
Calculate the decision parameter.
Pk
= 2ΔY – ΔX
= 2 x 8 – 10
=6
So, decision parameter Pk = 6
Step-03:
As Pk >= 0, so case-02 is satisfied.
Thus,
• Pk+1 = Pk + 2ΔY – 2ΔX = 6 + (2 x 8) – (2 x 10) = 2
• Xk+1 = Xk + 1 = 20 + 1 = 21
• Yk+1 = Yk + 1 = 10 + 1 = 11
DDA Algorithm.
• It uses fixed points only.
Disadvantages of Bresenham Line Drawing Algorithm-
The disadvantages of Bresenham Line Drawing Algorithm are-Though
it improves the accuracy of generated points but still the resulted line is
not smooth.This algorithm is for the basic line drawing.It can not handle
diminishing jaggies.
Q2) Midpoint Ellipse Algorithm:
This is an incremental method for scan converting an ellipse that is
centered at the origin in standard position i.e., with the major and minor
axis parallel to coordinate system axis. It is very similar to the midpoint
circle algorithm. Because of the four-way symmetry property we need to
consider the entire elliptical curve in the first quadrant.
Let's first rewrite the ellipse equation and define the function f that can
be used to decide if the midpoint between two candidate pixels is inside
or outside the ellipse:
Now divide the elliptical curve from (0, b) to (a, 0) into two parts at point
Q where the slope of the curve is -1.
Aliasing :
In computer graphics, the process by which smooth curves and other
lines become jagged because the resolution of the graphics device or
file is not high enough to represent a smooth curve.
In the line drawing algorithms, we have seen that all rasterized
locations do not match with the true line and we have to select the
optimum raster locations to represent a straight line. This problem is
severe in low resolution screens. In such screens line appears like a
stair-step, as shown in the figure below. This effect is known
as aliasing. It is dominant for lines having gentle and sharp slopes.
Q4) Even Odd method & Winding number Method-Inside & Outside
Test of a Polygon
Introduction :
A polygon may be represented as a number of line segments
connected, end to form a closed figure.
Polygons can be represented in two ways –
(i) outline from using move commands and
(ii) as a solid objects by setting the pixels high inside the polygon
including pixels on the boundary.
To determine a point lies inside a polygon or not, in computer
graphics, we have two methods :
(a) Even-Odd method (odd-parity rule)
(b) Winding number Method-Inside
Even-Odd method :
Constructing a line segment between the point (P) to be examined
and a known point outside the polygon is the one way to determine a
point lies inside a polygon or not. The number of times the line
segment intersects the polygon boundary is then counted. The point
(P) is an internal point if the number of polygon edges intersected by
this line is odd; otherwise, the point is an external point.
In the figure, the line segment from ‘A’ crosses single edge & hence
point A is inside the polygon. The point B is also inside the polygon
as the line segment from B crosses three (odd) edges. But point C is
outside the polygon it as the line segment from C crosses two
(even) edges.
Polygon
But this even-odd test fails when the intersection point is a vertex.
To handle this case, we have to make few modifications.
We must look at the other end points of the two segments of a
polygon which meet at this vertex. If these points lies on the same
side of the constructed line A’P’, then the intersection point counts
as an even number of intersection. But if they lie on the opposite
side of constructed line AP, then the intersection points counts as a
single intersection.
Polygon
As we can see the line segment A’P’ intersects at M which is a
vertex and L & Z are the other end points of the two segments
meeting at M. L & Z lie on same side of the line segment A’P’, so
the count is taken as even.
Winding Number Method :
There is another alternative method for defining a polygons’ interior
point is called the winding number method. Conceptually, one can
stretch a piece of elastic between the point (P) to be checked and the
point on the polygon boundary.
Treat that, elastic is tied to point (P) to be checked firmly and the
other end of the elastic is sliding along the boundary of the polygon
until it has made one complete circuit. Then we check that how
many times the elastic has been wound around the point of
intersection. If it is wound at-least once, point is inside. If there is no
net winding then point is outside.
In this method, instead of just counting the intersections, we give
each boundary line crossed a direction number, and we sum these
directions numbers. The direction number indicates the direction of
the polygon edge was drawn relative to the line segment we
constructed for the test.
Example : To test a point (xi, yi), let us consider a horizontal line
segment y = yi which runs from outside the polygon to (xi, yi). We
find all the sides which crossed this line segment.
Now there are 2 ways for side to cross, the side could be drawn
starting below end, cross it and end above the line. In this case we
can give direction numbers – 1, to the side or the edge could start
above the line & finish below it in this case, given a direction 1. The
sum of the direction numbers for the sides that cross the constructed
horizontal line segment yield the “Winding Number” for the point.
If the winding number is non-zero , the point is interior to polygon,
else, exterior to polygon.
Polygon
In the above figure, the line segment crosses 4 edges having
different direction numbers : 1, -1, 1& -1 respectively, then :
Winding Number = 1 + (-1) + 1 + (-1) = 0
So the point P is outside the Polygon. The edge has direction
Number -1 because it starts below the line segment & finishes
above. Similarly, edge has direction Number +1 because it starts
from above the line segment & finishes below the line segment
Q5) Comparisons between DDA and Bresenham Line Drawing
algorithm
In lighting tricks, there are 2 algorithmic rules used for drawing a
line over the screen that’s DDA stands for Digital Differential
Analyser algorithmic rule and Bresenham line algorithm.
1.
2.
Play
DDA Algorithm-
DDA Algorithm is the simplest line drawing algorithm.
Procedure-
Given-
Starting coordinates = (X0, Y0)
•
Step-02:
Find the number of steps or points in between the starting and
ending coordinates.
if (absolute (ΔX) > absolute (ΔY))
Problem-02:
Calculate the points between the starting point (5, 6) and ending
point (13, 10).
Solution-
Given-
• Starting coordinates = (X0, Y0) = (5, 6)
• Ending coordinates = (Xn, Yn) = (13, 10)
Step-01:
Calculate ΔX, ΔY and M from the given input.
• ΔX = Xn – X0 = 13 – 5 = 8
• ΔY =Yn – Y0 = 10 – 6 = 4
• M = ΔY / ΔX = 4 / 8 = 0.50
Step-02:
The points for other octacts are generated using the eight symmetry
property.
Procedure-
Given-
4. Centre point of Circle = (X0, Y0)
5. Radius of Circle = R
Step-01:
Assign the starting point coordinates (X0, Y0) as-
X0 = 0
• Y0 = R
Step-02:
Calculate the value of initial decision parameter P0 as-
P0 = 1 – R
Step-03:
Suppose the current point is (Xk, Yk) and the next point is (Xk+1, Yk+1).
Find the next point of the first octant depending on the value of decision
parameter Pk.
Follow the below two cases-
Step-04:
If the given centre point (X0, Y0) is not (0, 0), then do the
following and plot the point-
Xplot = Xc + X0
• Yplot = Yc + Y0
Step-06:
Problem-01:
Given the centre point coordinates (0, 0) and radius as 10, generate all the
points to form a circle.
Solution-
Given-
• Centre Coordinates of Circle (X0, Y0) = (0, 0)
• Radius of Circle = 10
Step-01:
• Y0 = R = 10
Step-02:
Step-03:
Thus,
• Xk+1 = Xk + 1 = 0 + 1 = 1
• Yk+1 = Yk = 10
• Pk+1 = Pk + 2 x Xk+1 + 1 = -9 + (2 x 1) + 1 = -6
Step-04
This step is not applicable here as the given centre point coordinates is (0,
0).
Step-05:
Pk+1 (Xk+1,
Pk Yk+1)
(0,
10)
-9 -6 (1,
10)
-6 -1 (2,
10)
-1 6 (3,
10)
6 -3 (4, 9)
-3 8 (5, 9)
8 5 (6, 8)
Algorithm calculates all the points of octant-1 and terminates.
Now, the points of octant-2 are obtained using the mirror effect by
swapping X and Y coordinates.
Octant- Octant-
1 Points 2 Points
(0, 10) (8, 6)
(1, 10) (9, 5)
(2, 10) (9, 4)
(3, 10) (10, 3)
(4, 9) (10, 2)
(5, 9) (10, 1)
(6, 8) (10, 0)
These are all
points for
Quadrant-1.
Now, the points for rest of the part are generated by following the signs of
other quadrants.
The other points can also be generated by calculating each octant
separately.
Here, all the points have been generated with respect to quadrant-1-
Given the centre point coordinates (4, -4) and radius as 10, generate all
the points to form a circle.
Solution-
Given-
• Centre Coordinates of Circle (X0, Y0) = (4, -4)
• Radius of Circle = 10
is (0, 0).
• At the end, we translate the circle.
• Yplot = Yc + Y0 = 4 + Y0
(Xk+1, (Xplot,
Yk+1) Yplot)
(0, 10) (4, 14)
(1, 10) (5, 14)
(2, 10) (6, 14)
(3, 10) (7, 14)
(4, 9) (8, 13)
(5, 9) (9, 13)
(6, 8) (10,
12)
(8, 6) (12,
10)
(9, 5) (13, 9)
(9, 4) (13, 8)
(10, 3) (14, 7)
(10, 2) (14, 6)
(10, 1) (14, 5)
(10, 0) (14, 4)
These are all
points for
Quadrant-1.
The following table shows the points for all the quadrants-
circle X2 + Y2 = R2.
• It is easy to implement from the programmer’s perspective.
algorithm.
• The circle generated by this algorithm is not smooth.
Transformation
Changing Position, shape, size, or orientation of an object on display is known as transformation.
Basic Transformation
• Basic transformation includes three transformations Translation, Rotation, and Scaling.
• These three transformations are known as basic transformation because with combination of these
three transformations we can obtain any transformation.
Translation
(𝒙′, 𝒚′)
𝒕𝒚
(𝒙, 𝒚)
𝒕𝒙
1
Unit-3 – 2D Transformation & Viewing
Rotation
• It is a transformation that used to reposition the object along the circular path in the XY - plane.
• To generate a rotation we specify a rotation angle 𝜽 and the position of the Rotation Point (Pivot
Point) (𝒙𝒓,𝒚𝒓) about which the object is to be rotated.
• Positive value of rotation angle defines counter clockwise rotation and negative value of rotation angle
defines clockwise rotation.
• We first find the equation of rotation when pivot point is at coordinate origin(𝟎, 𝟎).
(𝒙′, 𝒚′)
(𝒙, 𝒚)
𝜽
2
Unit-3 – 2D Transformation & Viewing
𝒙′ 𝒙
= 𝐜𝐨𝐬 𝜽 − 𝐬𝐢𝐧 𝜽 ∙
[𝒚′] [ ] [𝒚]
𝐬𝐢𝐧 𝜽 𝐜𝐨𝐬 𝜽
• Rotation about arbitrary point is illustrated in below figure.
(𝒙′, 𝒚′)
(𝒙, 𝒚)
𝜽
∅
(𝒙𝒓, 𝒚𝒓)
Scaling
Fixed Point
4
Unit-3 – 2D Transformation & Viewing
𝑠𝑥 0 2 6 6 2
𝑃′ = [ ][ ]
0 𝑠𝑦 2 2 6 6
′
𝑃 =[ 0.5 0 ] [2 6 6 2]
0 0.5 2 2 6 6
1 3 3 1
𝑃′ = [ ]
1 1 3 3
• Final coordinate after scaling are [A’ (1, 1), B’ (3, 1), C’ (3, 3), D’ (1, 3)].
𝑷′ = 𝑻(𝒕 𝒙,𝒕 𝒚) ∙ 𝑷
𝒙′ 𝟏 𝟎 𝒕𝒙 𝒙
[𝒚′] = [𝟎 𝟏 𝒕𝒚] [𝒚]
𝟏 𝟎 𝟎 𝟏 𝟏
NOTE: - Inverse of translation matrix is obtain by putting −𝒕𝒙 & − 𝒕𝒚 instead of 𝒕𝒙 & 𝒕𝒚.
Rotation
𝑷′ = 𝑹(𝜽) ∙ 𝑷
𝒙′ 𝐜𝐨𝐬 𝜽 − 𝐬𝐢𝐧 𝜽 𝟎 𝒙
[𝒚′] = [𝐬𝐢𝐧 𝜽 𝐜𝐨𝐬 𝜽 𝟎] [𝒚]
𝟏 𝟎 𝟎 𝟏 𝟏
NOTE: - Inverse of rotation matrix is obtained by replacing 𝜽 by −𝜽.
Scaling
𝑷′ = 𝑺(𝒔𝒙,𝒔𝒚) ∙ 𝑷
5
Unit-3 – 2D Transformation & Viewing
𝒙′ 𝒔𝒙 𝟎 𝟎 𝒙
[𝒚′] = [ 𝟎 𝒔𝒚 𝟎] [𝒚]
𝟏 𝟎 𝟎 𝟏 𝟏
NOTE: - Inverse of scaling matrix is obtained by replacing 𝒔𝒙 & 𝒔𝒚 by 𝟏 & 𝟏 respectively.
𝒔𝒙 𝒔𝒚
Composite Transformation
• We can set up a matrix for any sequence of transformations as a composite transformation matrix by
calculating the matrix product of individual transformation.
• For column matrix representation of coordinate positions, we form composite transformations by
multiplying matrices in order from right to left.
Translations
• Two successive translations are performed as:
𝑷′ = 𝑻(𝒕𝒙𝟐, 𝒕𝒚𝟐) ∙ {𝑻(𝒕𝒙𝟏, 𝒕𝒚𝟏) ∙ 𝑷}
𝑷′ = {𝑻(𝒕𝒙𝟐, 𝒕𝒚𝟐) ∙ 𝑻(𝒕𝒙𝟏, 𝒕𝒚𝟏)} ∙ 𝑷
𝟏 𝟎 𝒕𝒙𝟐 𝟏 𝟎 𝒕𝒙𝟏
𝑷 = [𝟎 𝟏 𝒕𝒚𝟐] [𝟎 𝟏 𝒕𝒚𝟏] ∙ 𝑷
′
𝟎 𝟎 𝟏 𝟎 𝟎 𝟏
𝟏 𝟎 𝒕𝒙𝟏 + 𝒕𝒙𝟐
𝑷′ = [𝟎 𝟏 𝒕𝒚𝟏 + 𝒕𝒚𝟐] ∙ 𝑷
𝟎 𝟎 𝟏
𝑷′ = 𝑻(𝒕𝒙𝟏 + 𝒕𝒙𝟐, 𝒕𝒚𝟏 + 𝒕𝒚𝟐) ∙ 𝑷}
Here 𝑷′ and 𝑷 are column vector of final and initial point coordinate respectively.
• This concept can be extended for any number of successive translations.
Example: Obtain the final coordinates after two translations on point 𝑝(2,3) with translation vector
(4, 3) and (−1, 2) respectively.
Rotations
• Two successive Rotations are performed as:
𝑷′ = 𝑹(𝜽𝟐) ∙ {𝑹(𝜽𝟏) ∙ 𝑷}
𝑷′ = {𝑹(𝜽𝟐) ∙ 𝑹(𝜽𝟏)} ∙ 𝑷
𝐜𝐨𝐬 𝜽𝟐 − 𝐬𝐢𝐧 𝜽𝟐 𝟎 𝐜𝐨𝐬 𝜽𝟏 −𝐬𝐢𝐧 𝜽𝟏 𝟎
𝑷 = [𝐬𝐢𝐧 𝜽𝟐
′ 𝐜𝐨𝐬 𝜽𝟐 𝟎] [𝐬𝐢𝐧 𝜽𝟏 𝐜𝐨𝐬 𝜽𝟏 𝟎] ∙ 𝑷
𝟎 𝟎 𝟏 𝟎 𝟎 𝟏
𝐜𝐨𝐬 𝜽𝟐 𝐜𝐨𝐬 𝜽𝟏 − 𝐬𝐢𝐧 𝜽𝟐 𝐬𝐢𝐧 𝜽𝟏 − 𝐬𝐢𝐧 𝜽𝟏 𝐜𝐨𝐬 𝜽𝟐 − 𝐬𝐢𝐧 𝜽𝟐 𝐜𝐨𝐬 𝜽𝟏 𝟎
𝑷′ = [𝐬𝐢𝐧 𝜽𝟏 𝐜𝐨𝐬 𝜽𝟐 + 𝐬𝐢𝐧 𝜽𝟐 𝐜𝐨𝐬 𝜽𝟏 𝐜𝐨𝐬 𝜽𝟐 𝐜𝐨𝐬 𝜽𝟏 − 𝐬𝐢𝐧 𝜽𝟐 𝐬𝐢𝐧 𝜽𝟏 𝟎] ∙ 𝑷
𝟎 𝟎 𝟏
6
Unit-3 – 2D Transformation & Viewing
𝐜𝐨𝐬(𝜽𝟏 + 𝜽𝟐) −𝐬𝐢𝐧(𝜽𝟏 + 𝜽𝟐) 𝟎
𝑷′ = [𝐬𝐢𝐧(𝜽𝟏 + 𝜽𝟐) 𝐜𝐨𝐬(𝜽𝟏 + 𝜽𝟐) 𝟎] ∙ 𝑷
𝟎 𝟎 𝟏
𝑷′ = 𝑹(𝜽𝟏 + 𝜽𝟐) ∙ 𝑷
Here 𝑷′ and 𝑷 are column vector of final and initial point coordinate respectively.
• This concept can be extended for any number of successive rotations.
Example: Obtain the final coordinates after two rotations on point 𝑝(6,9) with rotation angles are 30𝑜 and
60𝑜 respectively.
𝑃′ = 𝑅(𝜃1 + 𝜃2) ∙ 𝑃
𝑐𝑜𝑠(𝜃1 + 𝜃2) −𝑠𝑖𝑛(𝜃1 + 𝜃2) 0
𝑃′ = [𝑠𝑖𝑛(𝜃1 + 𝜃2) 𝑐𝑜𝑠(𝜃1 + 𝜃2) 0] ∙ 𝑃 0
0 1
𝑐𝑜𝑠(30 + 60) −𝑠𝑖𝑛(30 + 60) 0
𝑃′ = [𝑠𝑖𝑛(30 + 60) 𝑐𝑜𝑠(30 + 60) 0] ∙ 𝑃 0
0 1
0 −1 0 6 −9
𝑃′ = [1 0 0] ∙ [9] = [ 6 ]
0 0 1 1 1
Final Coordinates after rotations are 𝑝,(−9, 6).
Scaling
• Two successive scaling are performed as:
𝑷′ = 𝑺(𝒔𝒙𝟐, 𝒔𝒚𝟐) ∙ {𝑺(𝒔𝒙𝟏, 𝒔𝒚𝟏) ∙ 𝑷}
𝑷′ = {𝑺(𝒔𝒙𝟐, 𝒔𝒚𝟐) ∙ 𝑺(𝒔𝒙𝟏, 𝒔𝒚𝟏)} ∙ 𝑷
𝒔𝒙𝟐 𝟎 𝟎 𝒔𝒙𝟏 𝟎 𝟎
𝑷′ = [ 𝟎 𝒔𝒚𝟐 𝟎] [ 𝟎 𝒔𝒚𝟏 𝟎] ∙ 𝑷
𝟎 𝟎 𝟏 𝟎 𝟎 𝟏
𝒔𝒙𝟏 ∙ 𝒔𝒙𝟐 𝟎 𝟎
𝑷′ = [ 𝟎 𝒔𝒚𝟏 ∙ 𝒔𝒚𝟐 𝟎] ∙ 𝑷
𝟎 𝟎 𝟏
𝑷′ = 𝑺(𝒔𝒙𝟏 ∙ 𝒔𝒙𝟐, 𝒔𝒚𝟏 ∙ 𝒔𝒚𝟐) ∙ 𝑷
Here 𝑷′ and 𝑷 are column vector of final and initial point coordinate respectively.
• This concept can be extended for any number of successive scaling.
Example: Obtain the final coordinates after two scaling on line 𝑝𝑞 [𝑝(2,2), 𝑞(8, 8)] with scaling factors are
(2, 2) and (3, 3) respectively.
Final Coordinates after rotations are 𝑝,(12, 12) and 𝑞,(48, 48).
7
Unit-3 – 2D Transformation & Viewing
8
Unit-3 – 2D Transformation & Viewing
11 13 18
𝑃′ = [ 7 4 4]
1 1 1
• Final coordinates after rotation are [A’ (11, 7), B’ (13, 4), C’ (18, 4)].
(c) (d)
(a) (b)
Scale Object with Translate Object so that
Original Position Translate Object so
Respect to Origin Fixed Point is Return to
of Object and that Fixed Point
Position (𝒙𝒇, 𝒚𝒇) .
Fixed Point (𝒙𝒇, 𝒚𝒇) is at Origin
𝟎 𝟎 𝟏 𝟎 𝟎 𝟏 𝟎 𝟎 𝟏
𝒔𝒙 𝟎 𝒙𝒇(𝟏 − 𝒔𝒙)
𝑷′ = [ 𝟎 𝒔𝒚 𝒚𝒇(𝟏 − 𝒔𝒚)] ∙ 𝑷
𝟎 𝟎 𝟏
𝑷 = 𝑺(𝒙𝒇, 𝒚𝒇, 𝒔𝒙, 𝒔𝒚) ∙ 𝑷
′
Here 𝑷′ and 𝑷 are column vector of final and initial point coordinate respectively and (𝒙𝒇, 𝒚𝒇) are the
coordinates of fixed-point.
• Example: - Consider square with left-bottom corner at (2, 2) and right-top corner at (6, 6) apply the
transformation which makes its size half such that its center remains same.
Fixed point is center of square so:
6−2
𝑥 =2+ , 𝑦 6−2
𝑓 𝑓 =2+
2 2
As we want size half so value of scale factor are 𝑠𝑥 = 0.5, 𝑠𝑦 = 0.5 and Coordinates of square are [A (2,
2), B (6, 2), C (6, 6), D (2, 6)].
𝑃′ = 𝑆(𝑥𝑓, 𝑦𝑓, 𝑠𝑥, 𝑠𝑦) ∙ 𝑃
𝑠𝑥 0 𝑥𝑓(1 − 𝑠𝑥) 2 6 6 2
𝑃 = [ 0 𝑠𝑦 𝑦𝑓(1 − 𝑠𝑦)] [2 2 6 6]
′
0 0 1 1 1 1 1
9
Unit-3 – 2D Transformation & Viewing
0.5 0 4(1 − 0.5) 2 6 6 2
𝑃′ = [ 0 0.5 4(1 − 0.5)] [2 2 6 6]
0 0 1 1 1 1 1
0.5 0 2 2 6 6 2
𝑃′ = [ 0 0.5 2] [2 2 6 6]
0 0 1 1 1 1 1
3 5 5 3
𝑃′ = [3 3 5 5]
1 1 1 1
• Final coordinate after scaling are [A’ (3, 3), B’ (5, 3), C’ (5, 5), D’ (3, 5)]
𝒔𝟏
Reflection
10
Unit-3 – 2D Transformation & Viewing
• The mirror image for a two –dimensional reflection is generated relative to an axis of reflection by
rotating the object 180o about the reflection axis.
• Reflection gives image based on position of axis of reflection. Transformation matrix for few positions
are discussed here.
y
1 Original
Position
2 3
x
2’ 3’
Reflected
1’ Position
1 0 0
[0 −1 0]
0 0 1
y
1’ 1 Original
Reflected
Position Position
3’ 2’ 2 3
−1 0 0
[ 0 1 0]
0 0 1
11
Unit-3 – 2D Transformation & Viewing
y
Original
3 Position
1 2
1’ x
3’
Reflected 2’
Position
−1 0 0
[ 0 −1 0]
0 0 1
y
Original x=y line
Position
3
2 1
1’
3’
Reflected
2’ Position
0 1 0
[1 0 0]
0 0 1
12
Unit-3 – 2D Transformation & Viewing
x=-y line 3 y
1 2
Original
’ 1’
3 Position
2’
Reflected
Position
x
0 −1 0
[−1 0 0]
0 0 1
• Example: - Find the coordinates after reflection of the triangle [A (10, 10), B (15, 15), C (20, 10)] about x
axis.
1 0 0 10 15 20
𝑃 = [0 −1 0] [10 15 10 ]
′
0 0 1 1 1 1
10 15 20
𝑃′ = [−10 −15 −10]
1 1 1
• Final coordinate after reflection are [A’ (10, -10), B’ (15, -15), C’ (20, -10)]
Shear
• A transformation that distorts the shape of an object such that the transformed shape appears as if the
object were composed of internal layers that had been caused to slide over each other is called shear.
• Two common shearing transformations are those that shift coordinate x values and those that shift y
values.
Shear in 𝒙 − 𝒅𝒊𝒓𝒆𝒄𝒕𝒊𝒐𝒏 .
Before After
Y Shear Shear
Y
X X
13
Unit-3 – 2D Transformation & Viewing
0.5 1.5 2 1
𝑃′ = [ 0 0 1 1]
1 1 1 1
• Final coordinate after shear are [A’ (0.5, 0), B’ (1.5, 0), C’ (2, 1), D’ (1, 1)]
Shear in 𝒚 − 𝒅𝒊𝒓𝒆𝒄𝒕𝒊𝒐𝒏 .
Before
Y Shear After
Y
Shear
X X
Fig. 3.1: - A viewing transformation using standard rectangles for the window and viewport.
• Now we see steps involved in viewing pipeline.
15
Unit-3 – 2D Transformation & Viewing
Fig. 3.3: - A viewing-coordinate frame is moved into coincidence with the world frame in two steps: (a)
translate the viewing origin to the world origin, and then (b) rotate to align the axes of the two systems.
• We can obtain reference frame in any direction and at any position.
• For handling such condition first of all we translate reference frame origin to standard reference frame
origin and then we rotate it to align it to standard axis.
• In this way we can adjust window in any reference frame.
• this is illustrate by following transformation matrix:
16
Unit-3 – 2D Transformation & Viewing
𝐌𝐰𝐜,𝐯𝐜 = 𝐑𝐓
• Where T is translation matrix and R is rotation matrix.
Window-To-Viewport Coordinate Transformation
• Mapping of window coordinate to viewport is called window to viewport transformation.
• We do this using transformation that maintains relative position of window coordinate into viewport.
• That means center coordinates in window must be remains at center position in viewport.
• We find relative position by equation as follow:
𝐱𝐯 − 𝐱𝐯𝐦𝐢𝐧 𝐱 − 𝐱𝐰𝐦𝐢𝐧
= 𝐰
𝐱𝐯𝐦𝐚𝐱 − 𝐱𝐯𝐦𝐢𝐧 𝐱𝐰𝐦𝐚𝐱 − 𝐱𝐰𝐦𝐢𝐧
𝐲𝐯 − 𝐲𝐯𝐦𝐢𝐧 𝐲 − 𝐲𝐰𝐦𝐢𝐧
= 𝐰
𝐲𝐯𝐦𝐚𝐱 − 𝐲𝐯𝐦𝐢𝐧 𝐲𝐰𝐦𝐚𝐱 − 𝐲𝐰𝐦𝐢𝐧
• Solving by making viewport position as subject we obtain:
𝐱𝐯 = 𝐱𝐯𝐦𝐢𝐧 + (𝐱𝐰 − 𝐱𝐰𝐦𝐢𝐧)𝐬𝐱
𝐲𝐯 = 𝐲𝐯𝐦𝐢𝐧 + (𝐲𝐰 − 𝐲𝐰𝐦𝐢𝐧)𝐬𝐲
• Where scaling factor are :
𝐱𝐯𝐦𝐚𝐱 − 𝐱𝐯𝐦𝐢𝐧
𝐬𝐱 = 𝐱
𝐰𝐦𝐚𝐱 − 𝐱𝐰𝐦𝐢𝐧
𝐲𝐯𝐦𝐚𝐱 − 𝐲𝐯𝐦𝐢𝐧
𝐬𝐲 =
𝐲𝐰𝐦𝐚𝐱 − 𝐲𝐰𝐦𝐢𝐧
• We can also map window to viewport with the set of transformation, which include following sequence
of transformations:
1. Perform a scaling transformation using a fixed-point position of (xWmin,ywmin) that scales the window
area to the size of the viewport.
2. Translate the scaled window area to the position of the viewport.
• For maintaining relative proportions we take (sx = sy). in case if both are not equal then we get stretched
or contracted in either the x or y direction when displayed on the output device.
• Characters are handle in two different way one way is simply maintain relative position like other
primitive and other is to maintain standard character size even though viewport size is enlarged or
reduce.
• Number of display device can be used in application and for each we can use different window-to-
viewport transformation. This mapping is called the workstation transformation.
17
Unit-3 – 2D Transformation & Viewing
• As shown in figure two different displays devices are used and we map different window-to-viewport on
each one.
Clipping Operations
• Generally, any procedure that identifies those portions of a picture that are either inside or outside of a
specified region of space is referred to as a clipping algorithm, or simply clipping. The region against
which an object is to clip is called a clip window.
• Clip window can be general polygon or it can be curved boundary.
Application of Clipping
• It can be used for displaying particular part of the picture on display screen.
• Identifying visible surface in 3D views.
• Antialiasing.
• Creating objects using solid-modeling procedures.
• Displaying multiple windows on same screen.
• Drawing and painting.
Point Clipping
• In point clipping we eliminate those points which are outside the clipping window and draw points which
are inside the clipping window.
• Here we consider clipping window is rectangular boundary with edge (xwmin,xwmax,ywmin,ywmax).
• So for finding wether given point is inside or outside the clipping window we use following inequality:
𝒙𝒘𝒎𝒊𝒏 ≤ 𝒙 ≤ 𝒙𝒘𝒂𝒎𝒙
𝒚𝒘𝒎𝒊𝒏 ≤ 𝒚 ≤ 𝒚𝒘𝒂𝒎𝒙
• If above both inequality is satisfied then the point is inside otherwise the point is outside the clipping
window.
Line Clipping
• Line clipping involves several possible cases.
1. Completely inside the clipping window.
2. Completely outside the clipping window.
3. Partially inside and partially outside the clipping window.
P9
Window Window
P4 P10
P2 P2
P8
P1 P1
P5 P5 P6 P8
P3 P6
P7
P7
18
Unit-3 – 2D Transformation & Viewing
• Line which is completely inside is display completely. Line which is completely outside is eliminated from
display. And for partially inside line we need to calculate intersection with window boundary and find
which part is inside the clipping boundary and which part is eliminated.
• For line clipping several scientists tried different methods to solve this clipping procedure. Some of them
are discuss below.
Cohen-Sutherland Line Clipping
• This is one of the oldest and most popular line-clipping procedures.
Algorithm
Step-1:
Assign region code to both endpoint of a line depending on the position where the line endpoint is located.
Step-2:
If both endpoint have code ‘0000’
Then line is completely inside.
Otherwise
Perform logical ending between this two codes.
19
Unit-3 – 2D Transformation & Viewing
Step-3:
Draw line segment which are completely inside and eliminate other line segment which found completely
outside.
Algorithm
1. Read two end points of line 𝑃1(𝑥1, 𝑦1) and 𝑃2(𝑥2, 𝑦2)
2. Read two corner vertices, left top and right bottom of window: (𝑥𝑤𝑚𝑖𝑛, 𝑦𝑤𝑚𝑎𝑥) and (𝑥𝑤𝑚𝑎𝑥, 𝑦𝑤𝑚𝑖𝑛)
3. Calculate values of parameters 𝑝𝑘 and 𝑞𝑘 for 𝑘 = 1, 2, 3, 4 such that,
𝑝1 = −∆𝑥, 𝑞1 = 𝑥1 − 𝑥𝑤𝑚𝑖𝑛
𝑝2 = ∆𝑥, 𝑞2 = 𝑥𝑤𝑚𝑎𝑥 − 𝑥1
𝑝3 = −∆𝑦, 𝑞3 = 𝑦1 − 𝑦𝑤𝑚𝑖𝑛
𝑝4 = ∆𝑦, 𝑞4 = 𝑦𝑤𝑚𝑎𝑥 − 𝑦1
4. If 𝑝𝑘 = 0 for any value of 𝑘 = 1, 2, 3, 4 then,
Line is parallel to 𝑘𝑡ℎ boundary.
20
Unit-3 – 2D Transformation & Viewing
Use boundary coordinates to draw line. And go to Step 8.
5. For 𝑘 = 1,2,3,4 calculate 𝑟𝑘 for nonzero values of 𝑝𝑘 and 𝑞𝑘 as follows:
𝑞𝑘
𝑟𝑘 = , 𝑓𝑜𝑟 𝑘 = 1,2,3,4
𝑝𝑘
6. Find 𝑢1 𝑎𝑛𝑑 𝑢2 as given below:
𝑢1 = max{0, 𝑟𝑘|𝑤ℎ𝑒𝑟𝑒 𝑘 𝑡𝑎𝑘𝑒𝑠 𝑎𝑙𝑙 𝑣𝑎𝑙𝑢𝑒𝑠 𝑓𝑜𝑟 𝑤ℎ𝑖𝑐ℎ 𝑝𝑘 < 0}
𝑢2 = min{1, 𝑟𝑘|𝑤ℎ𝑒𝑟𝑒 𝑘 𝑡𝑎𝑘𝑒𝑠 𝑎𝑙𝑙 𝑣𝑎𝑙𝑢𝑒𝑠 𝑓𝑜𝑟 𝑤ℎ𝑖𝑐ℎ 𝑝𝑘 > 0}
7. If 𝑢1 ≤ 𝑢2 then
Calculate endpoints of clipped line:
𝑥1′ = 𝑥1 + 𝑢1∆𝑥
𝑦1′ = 𝑦1 + 𝑢1∆𝑦
𝑥2′ = 𝑥1 + 𝑢2∆𝑥
𝑦2′ = 𝑦1 + 𝑢2∆𝑦
Draw line (𝑥1′, 𝑦1′, 𝑥2′, 𝑦2′);
8. Stop.
Advantages
1. More efficient.
2. Only requires one division to update 𝑢1 and 𝑢2.
3. Window intersections of line are calculated just once.
P1
P1 P1
Fig. 3.7: - Three possible position for a line endpoint p1 in the NLN line-clipping algorithm.
• We can also extend this procedure for all nine regions.
• Now for p1 is inside the window we divide whole area in following region:
21
Unit-3 – 2D Transformation & Viewing
Fig. 3.10: - Two possible sets of clipping region when p1 is in corner region.
• Regions are name in such a way that name in which region p2 falls is gives the window edge which
intersects the line.
• For example region LT says that line need to clip at left and top boundary.
• For finding that in which region line 𝒑𝟏𝒑𝟐 falls we compare the slope of the line to the slope of the
boundaries:
𝒔𝒍𝒐𝒑𝒆 𝒑𝟏𝒑𝑩𝟏 < 𝒔𝒍𝒐𝒑𝒆 𝒑𝟏𝒑𝟐 < 𝑠𝑙𝑜𝑝𝑒 𝒑𝟏𝒑𝑩𝟐
Where 𝒑𝟏𝒑𝑩𝟏 and 𝒑𝟏𝒑𝑩𝟐 are boundary lines.
• For example p1 is in edge region and for checking whether p2 is in region LT we use following equation.
Polygon Clipping
• For polygon clipping we need to modify the line clipping procedure because in line clipping we need to
consider about only line segment while in polygon clipping we need to consider the area and the new
boundary of the polygon after clipping.
Sutherland-Hodgeman Polygon Clipping
• For correctly clip a polygon we process the polygon boundary as a whole against each window edge.
• This is done by whole polygon vertices against each clip rectangle boundary one by one.
• Beginning with the initial set of polygon vertices we first clip against the left boundary and produce new
sequence of vertices.
• Then that new set of vertices is clipped against the right boundary clipper, a bottom boundary clipper
and a top boundary clipper, as shown in figure below.
Fig. 3.12: - Processing the vertices of the polygon through boundary clipper.
• There are four possible cases when processing vertices in sequence around the perimeter of a polygon.
23
Unit-3 – 2D Transformation & Viewing
Fig. 3.13: - Clipping a polygon against successive window boundaries.
• As shown in case 1: if both vertices are inside the window we add only second vertices to output list.
• In case 2: if first vertices is inside the boundary and second vertices is outside the boundary only the
edge intersection with the window boundary is added to the output vertex list.
• In case 3: if both vertices are outside the window boundary nothing is added to window boundary.
• In case 4: first vertex is outside and second vertex is inside the boundary, then adds both intersection
point with window boundary, and second vertex to the output list.
• When polygon clipping is done against one boundary then we clip against next window boundary.
• We illustrate this method by simple example.
Window
3
2’
2 1’
1 3’ 4
6
5’
4’
5
V2’ V
2
(resume) V1’
V3’ V3
V4’
V1
V4
(stop)
V5’
(resume) V7’
V5
V6 V6’
(a) (b)
Fig. 3.14: - Clipping a concave polygon (a) with the Weiler-Atherton algorithm generates the two se
• As shown in figure we start from v1 and move clockwise towards v2 and add intersection point and next
point to output list by following polygon boundary, then from v2 to v3 we add v3 to output list.
• From v3 to v4 we calculate intersection point and add to output list and follow window boundary.
• Similarly from v4 to v5 we add intersection point and next point and follow the polygon boundary, next
we move v5 to v6 and add intersection point and follow the window boundary, and finally v6 to v1 is
outside so no need to add anything.
• This way we get two separate polygon section after clipping.
25
Unit-4 – 3D Concept & Object Representation
Perspective projection
• This method generating view of 3D object by projecting point on the display plane along converging
paths.
Depth cueing
• Many times depth information is important so that we can identify for a particular viewing direction
which are the front surfaces and which are the back surfaces of display object.
1
Unit-4 – 3D Concept & Object Representation
• Simple method to do this is depth cueing in which assign higher intensity to closer object & lower
intensity to the far objects.
• Depth cuing is applied by choosing maximum and minimum intensity values and a range of distance over
which the intensities are to vary.
• Another application is to modeling effect of atmosphere.
Surface Rendering
• More realistic image is produce by setting surface intensity according to light reflect from that surface &
the characteristics of that surface.
• It will give more intensity to the shiny surface and less to dull surface.
• It also applies high intensity where light is more & less where light falls is less.
CRT
Viewer
2
Unit-4 – 3D Concept & Object Representation
• Vibrating mirror changes its focal length due to vibration which is synchronized with the display of an
object on CRT.
• The each point on the object is reflected from the mirror into spatial position corresponding to distance
of that point from a viewing position.
• Very good example of this system is GENISCO SPACE GRAPH system, which use vibrating mirror to
project 3D objects into a 25 cm by 25 cm by 25 cm volume. This system is also capable to show 2D cross
section at different depth.
• Another way is stereoscopic views.
• Stereoscopic views does not produce three dimensional images, but it produce 3D effects by presenting
different view to each eye of an observer so that it appears to have depth.
• To obtain this we first need to obtain two views of object generated from viewing direction
corresponding to each eye.
• We can contract the two views as computer generated scenes with different viewing positions or we can
use stereo camera pair to photograph some object or scene.
• When we see simultaneously both the view as left view with left eye and right view with right eye then
two views is merge and produce image which appears to have depth.
• One way to produce stereoscopic effect is to display each of the two views with raster system on
alternate refresh cycles.
• The screen is viewed through glasses with each lance design such a way that it act as a rapidly
alternating shutter that is synchronized to block out one of the views.
Polygon Surfaces
• A polygonal surface can be thought of as a surface composed of polygonal faces.
• The most commonly used boundary representation for a three dimensional object is a set of polygon
surfaces that enclose the object interior
Polygon Tables
• Representation of vertex coordinates, edges and other property of polygon into table form is called
polygon table.
• Polygon data tables can be organized into two groups: geometric table and attributes table.
• Geometric table contains vertex coordinate and the other parameter which specify geometry of polygon.
• Attributes table stores other information like Color, transparency etc.
• Convenient way to represent geometric table into three different table namely vertex table, edge table,
and polygon table.
3
Unit-4 – 3D Concept & Object Representation
V1
E1
V2 E3
S1 E6
E2
S2
V3 V5
E4 E5
V4
Edge Table
Vertex Table
E1: V1, V2
V1: X1, Y1, Z1 Polygon Surface
E2: V2, V3
V2: X2, Y2, Z2 Table
E3: V3, V1
V3: X3, Y3, Z3 S1: E1, E2, E3
E4: V3, V4
V4: X4, Y4, Z4 S2: E3, E4, E5, E6
E5: V4, V5
V5: X5, Y5, Z5
E6: V5, V1
Fig. 4.5: - Edge table of above example with extra information as surface pointer.
• Now if any surface entry in polygon table will find edge in edge table it will verify whether this edge is of
particular surface’s edge or not if not it will detect errors and may be correct if sufficient information is
added.
4
Unit-4 – 3D Concept & Object Representation
Plane Equations
• For producing display of 3D objects we must process the input data representation for the object
through several procedures.
• For this processing we sometimes need to find orientation and it can be obtained by vertex coordinate
values and the equation of polygon plane.
• Equation of plane is given as
𝐴𝑥 + 𝐵𝑦 + 𝐶𝑧 + 𝐷 = 0
• Where (x, y, z) is any point on the plane and A, B, C, D are constants by solving three plane equation for
three non collinear points. And solve simultaneous equation for ratio A/D, B/D, and C/D as follows
𝐴 𝐵 𝐶
𝑥1 + 𝑦1 + 𝑧1 = −1
𝐷 𝐷 𝐷
𝐴 𝐵 𝐶
𝑥2 + 𝑦2 + 𝑧2 = −1
𝐷 𝐷 𝐷
𝐴 𝐵 𝐶
𝑥3 + 𝑦3 + 𝑧3 = −1
𝐷 𝐷 𝐷
• Solving by determinant
1 𝑦1 𝑧1 𝑥1 1 𝑧1 𝑥1 𝑦1 1 𝑥1 𝑦1 𝑧1
𝐴 = |1 𝑦2 𝑧2| 𝐵 = |𝑥2 1 𝑧2| 𝐶 = |𝑥2 𝑦2 1| 𝐷 = − |𝑥2 𝑦2 𝑧2|
1 𝑦3 𝑧3 𝑥3 1 𝑧3 𝑥3 𝑦3 1 𝑥3 𝑦3 𝑧3
• By expanding a determinant we get
𝐴 = 𝑦1(𝑧2 − 𝑧3) + 𝑦2(𝑧3 − 𝑧1) + 𝑦3(𝑧1 − 𝑧2)
𝐵 = 𝑧1(𝑥2 − 𝑥3) + 𝑧2(𝑥3 − 𝑥1) + 𝑧3(𝑥1 − 𝑥2)
𝐶 = 𝑥1(𝑦2 − 𝑦3) + 𝑥2(𝑦3 − 𝑦1) + 𝑥3(𝑦1 − 𝑦2)
𝐷 = −𝑥1(𝑦2𝑧3 − 𝑦3𝑧2) − 𝑥2(𝑦3𝑧1 − 𝑦1𝑧3) − 𝑥3(𝑦1𝑧2 − 𝑦2𝑧1)
• This values of A, B, C, D are then store in polygon data structure with other polygon data.
• Orientation of plane is described with normal vector to the plane.
N= (A, B, C)
Y
X
Z
Fig. 4.6: - the vector N normal to the surface.
• Here N= (A,B,C) where A, B, C are the plane coefficient.
• When we are dealing with the polygon surfaces that enclose object interior we define the side of the
faces towards object interior is as inside face and outward side as outside face.
• We can calculate normal vector N for any particular surface by cross product of two vectors in counter
clockwise direction in right handed system then.
𝑁 = (𝑣2 − 𝑣1)𝑋(𝑣3 − 𝑣1)
• Now N gives values A, B, C for that plane and D can be obtained by putting these values in plane
equation for one of the vertices and solving for D.
• Using plane equation in vector form we can obtain D as
𝑁 ∙ 𝑃 = −𝐷
• Plane equation is also used to find position of any point compare to plane surface as follows
5
Unit-4 – 3D Concept & Object Representation
Polygon Meshes
Fig. 4.7: -A triangle strip formed with 11 triangle Fig. 4.8: -A quadrilateral mesh containing 12 quadrilaterals
connecting 13 vertices constructed from a 5 by 4 input vertex array
• Polygon mesh is a collection of edges, vertices and faces that defines the shape of the polyhedral object
in 3D computer graphics and solid modeling.
• An edge can be shared by two or more polygons and vertex is shared by at least two edges.
• Polygon mesh is represented in following ways
o Explicit representation
o Pointer to vertex list
o Pointer to edge list
Explicit Representation
• In explicit representation each polygon stores all the vertices in order in the memory as,
𝑃 = (((𝑥1, 𝑦1, 𝑧1), (𝑥2, 𝑦2, 𝑧2)), … , ((𝑥𝑚, 𝑦𝑚, 𝑧𝑚), (𝑥𝑛, 𝑦𝑛, 𝑧𝑛)))
• It process fast but requires more memory for storing.
Spline Representations
• Spline is flexible strip used to produce a smooth curve through a designated set of points.
• Several small weights are attached to spline to hold in particular position.
• Spline curve is a curve drawn with this method.
6
Unit-4 – 3D Concept & Object Representation
• The term spline curve now referred to any composite curve formed with polynomial sections satisfying
specified continuity condition at the boundary of the pieces.
• A spline surface can be described with two sets of orthogonal spline curves.
• Approximation Spline: - When curve section follows general control point path without necessarily
passing through any control point, the resulting curve is said to approximate the set of control points
and that curve is known as Approximation Spline.
• Spline curve can be modified by selecting different control point position.
• We can apply transformation on the curve according to need like translation scaling etc.
• The convex polygon boundary that encloses a set of control points is called convex hull.
Fig. 4.11: -convex hull shapes for two sets of control points.
• A poly line connecting the sequence of control points for an approximation spline is usually displayed to
remind a designer of the control point ordering. This set of connected line segment is often referred as
control graph of the curve.
• Control graph is also referred as control polygon or characteristic polygon.
7
Unit-4 – 3D Concept & Object Representation
Fig. 4.12: -Control-graph shapes for two different sets of control points.
Fig. 4.13: - Piecewise construction of a curve by joining two curve segments uses different orders of
continuity: (a) zero-order continuity only, (b) first-order continuity, and (c) second-order continuity.
• First order continuity is often sufficient for general application but some graphics package like cad
requires second order continuity for accuracy.
8
Unit-4 – 3D Concept & Object Representation
Hermit Interpolation
• It is named after French mathematician Charles hermit
9
Unit-4 – 3D Concept & Object Representation
• It is an interpolating piecewise cubic polynomial with specified tangent at each control points.
• It is adjusted locally because each curve section is depends on it’s end points only.
• Parametric cubic point function for any curve section is then given by:
𝑝(0) = 𝑝𝑘
𝑝(1) = 𝑝𝑘+1
𝑝′(0) = 𝑑𝑝𝑘
𝑝′′(1) = 𝑑𝑝𝑘+1
Where dpk & dpk+1 are values of parametric derivatives at point pk & pk+1 respectively.
• Vector equation of cubic spline is:
𝑝(𝑢) = 𝑎𝑢3 + 𝑏𝑢2 + 𝑐𝑢 + 𝑑
• Where x component of p is
• 𝑥(𝑢) = 𝑎𝑥𝑢3 + 𝑏𝑥𝑢2 + 𝑐𝑥𝑢 + 𝑑𝑥 and similarly y & z components
• Matrix form of above equation is
𝑎
𝑏
𝑃(𝑢) = [𝑢3 𝑢2 𝑢 1] [ ]
𝑐
𝑑
• Now derivatives of p(u) is p’(u)=3au2+2bu+c+0
• Matrix form of p’(u) is
𝑎
𝑏
𝑃′(𝑢) = [3𝑢2 2𝑢 1 0] [ ]
𝑐
𝑑
• Now substitute end point value of u as 0 & 1 in above equation & combine all four parametric equations
in matrix form:
𝑝𝑘 0 0 0 1 𝑎
𝑝𝑘+1 1 1 1 1 𝑏
[ ]=[ ][ ]
𝑑𝑝𝑘 0 0 1 0 𝑐
𝑑𝑝𝑘+1 3 2 1 0 𝑑
• Now solving it for polynomial co efficient
𝑎 2 −2 1 1 𝑝𝑘
𝑝
𝑏 −3 3 −2 −1] [ 𝑘+1
[𝑐] = [ 0 0 1 0 𝑑𝑝𝑘 ]
𝑑 1 0 0 0 𝑑𝑝𝑘+1
𝑎 𝑝𝑘
𝑏 𝑝𝑘+1
[𝑐] = 𝑀 𝐻 [ 𝑑𝑝𝑘 ]
𝑑 𝑑𝑝𝑘+1
• Now Put value of above equation in equation of 𝑝(𝑢)
2 −2 1 1 𝑝𝑘
−3 3 −2 −1 𝑝𝑘+1
𝑝(𝑢) = [𝑢3 𝑢2 𝑢 1] [ ][ ]
0 0 1 0 𝑑𝑝 𝑘
1 0 0 0 𝑑𝑝𝑘+1
𝑝𝑘
𝑝𝑘+1
𝑝(𝑢) = [2𝑢3 − 3𝑢2 + 1 − 2𝑢3 + 3𝑢2 𝑢3 − 2𝑢2 + 𝑢 𝑢3 − 𝑢2] [ ]
𝑑𝑝𝑘
𝑑𝑝𝑘+1
𝑝(𝑢) = 𝑝𝑘(2𝑢3 − 3𝑢2 + 1) + 𝑝𝑘+1(−2𝑢3 + 3𝑢2 ) + 𝑑𝑝𝑘(𝑢3 − 2𝑢2 + 𝑢) + 𝑑𝑝𝑘+1(𝑢3 − 𝑢2)
𝑝(𝑢) = 𝑝𝑘𝐻0(u) + 𝑝𝑘+1𝐻1(u) + 𝑑𝑝𝑘𝐻2(u) + 𝑑𝑝𝑘+1𝐻3(u)
Where 𝐻𝑘(u) for k=0 , 1 , 2 , 3 are referred to as blending functions because that blend the boundary
constraint values for curve section.
10
Unit-4 – 3D Concept & Object Representation
Cardinal Splines
• As like hermit spline cardinal splines also interpolating piecewise cubics with specified endpoint tangents
at the boundary of each section.
• But in this spline we need not have to input the values of endpoint tangents.
• In cardinal spline values of slope at control point is calculated from two immediate neighbor control
points.
• It’s spline section is completely specified by the 4-control points.
Fig. 4.16: -parametric point function p(u) for a cardinal spline section between control points pk and pk+1.
• The middle two are two endpoints of curve section and other two are used to calculate slope of
endpoints.
• Now parametric equation for cardinal spline is:
𝑝(0) = 𝑝𝑘
𝑝(1) = 𝑝1𝑘+1
𝑝′(0) = (1 − 𝑡)(𝑝 −𝑝 )
𝑘+1 𝑘−1
12
𝑝′(1) = (1 − 𝑡)(𝑝 −𝑝)
𝑘+2 𝑘
2
11
Unit-4 – 3D Concept & Object Representation
Where parameter t is called tension parameter since it controls how loosely or tightly the cardinal spline
fit the control points.
Fig. 4.17: -Effect of the tension parameter on the shape of a cardinal spline section.
• When t = 0 this class of curve is referred to as catmull-rom spline or overhauser splines.
• Using similar method like hermit we can obtain:
𝑝𝑘−1
𝑝𝑘
𝑝(𝑢) = [𝑢3 𝑢2 𝑢 1] ∙ 𝑀𝑐 ∙ [𝑝𝑘+1]
𝑝𝑘+2
• Where the cardinal matrix is
−𝑠 2 − 𝑠 𝑠 − 2 𝑠
2𝑠 𝑠 − 3 3 − 2𝑠 −𝑠
𝑀𝑐 = [ ]
−𝑠 0 𝑠 0
0 1 0 0
• With 𝑠 = (1 − 𝑡)⁄2
• Put value of Mc in equation of p(u)
−𝑠 2 − 𝑠 𝑠 − 2 𝑠 𝑝𝑘−1
2𝑠 𝑠 − 3 3 − 2𝑠 −𝑠
𝑝(𝑢) = [𝑢3 𝑢2 𝑢 1] ∙ [ ] ∙ [ 𝑝𝑘
−𝑠 0 𝑠 0 𝑝𝑘+1]
0 1 0 0 𝑝𝑘+2
𝑝(𝑢) = [−𝑠𝑢3 + 2𝑠𝑢2 − 𝑠𝑢 (2 − 𝑠)𝑢3 + (𝑠 − 3)𝑢2 + 1 (𝑠 − 2)𝑢3 + (3 − 𝑠)𝑢2 + 𝑠𝑢 𝑠𝑢3 − 𝑠𝑢2]
𝑝𝑘−1
𝑝𝑘
∙ [𝑝 ]
𝑘+1
𝑝𝑘+2
𝑝(𝑢) = 𝑝𝑘−1(−𝑠𝑢3 + 2𝑠𝑢2 − 𝑠𝑢) + 𝑝𝑘((2 − 𝑠)𝑢3 + (𝑠 − 3)𝑢2 + 1)
+ 𝑝𝑘+1((𝑠 − 2)𝑢3 + (3 − 𝑠)𝑢2 + 𝑠𝑢) + 𝑝𝑘+2(𝑠𝑢3 − 𝑠𝑢2)
𝑝(𝑢) = 𝑝𝑘−1𝐶𝐴𝑅0(𝑢) + 𝑝𝑘𝐶𝐴𝑅1(𝑢) + 𝑝𝑘+1𝐶𝐴𝑅2(𝑢) + 𝑝𝑘+2𝐶𝐴𝑅3(𝑢)
Where polynomial 𝐶𝐴𝑅𝑘(𝑢) 𝑓𝑜𝑟 𝑘 = 0,1,2,3 are the cardinals blending functions.
• Figure below shows this blending function shape for t = 0.
12
Unit-4 – 3D Concept & Object Representation
Fig. 4.18: -The cardinal blending function for t=0 and s=0.5.
Kochanek-Bartels spline
• It is extension of cardinal spline
• Two additional parameters are introduced into the constraint equation for defining kochanek-Bartels
spline to provide more flexibility in adjusting the shape of curve section.
• For this parametric equations are as follows:
𝑝(0) = 𝑝𝑘
𝑝(1) = 𝑝 1𝑘+1
𝑝′(0) = (1 − 𝑡)[(1 + 𝑏)(1 − 𝑐)(𝑝 − 𝑝 ) + (1 − 𝑏)(1 + 𝑐)(𝑝 − 𝑝 )]
𝑘 𝑘−1 𝑘+1 𝑘
2
1
𝑝 (1) = (1 − 𝑡)[(1 + 𝑏)(1 + 𝑐)(𝑝
′
− 𝑝 ) + (1 − 𝑏)(1 − 𝑐)(𝑝 − 𝑝 )]
𝑘+1 𝑘 𝑘+2 𝑘+1
2
Where ‘t’ is tension parameter same as used in cardinal spline.
• B is bias parameter and C is the continuity parameter.
• In this spline parametric derivatives may not be continuous across section boundaries.
• Bias B is used to adjust the amount that the curve bends at each end of section.
Fig. 4.19: -Effect of bias parameter on the shape of a Kochanek-Bartels spline section.
• Parameter c is used to controls continuity of the tangent vectors across the boundaries of section. If C is
nonzero there is discontinuity in the slope of the curve across section boundaries.
13
Unit-4 – 3D Concept & Object Representation
• It is used in animation paths in particular abrupt change in motion which is simulated with nonzero
values for parameter C.
Bezier Curves
• Bezier curve section can be fitted to any number of control points.
• Number of control points and their relative position gives degree of the Bezier polynomials.
• With the interpolation spline Bezier curve can be specified with boundary condition or blending function.
• Most convenient method is to specify Bezier curve with blending function.
• Consider we are given n+1 control point position from p0 to pn where pk = (xk, yk, zk).
• This is blended to gives position vector p(u) which gives path of the approximate Bezier curve is:
𝑛
𝑥(𝑢) = ∑ 𝑥𝑘𝐵𝐸𝑍𝑘,𝑛(𝑢)
𝑘=0
𝑛
𝑦(𝑢) = ∑ 𝑦𝑘𝐵𝐸𝑍𝑘,𝑛(𝑢)
𝑘=0
𝑛
𝑧(𝑢) = ∑ 𝑧𝑘𝐵𝐸𝑍𝑘,𝑛(𝑢)
𝑘=0
• Bezier curve is a polynomial of degree one less than the number of control points.
• Below figure shows some possible curve shapes by selecting various control point.
14
Unit-4 – 3D Concept & Object Representation
Fig. 4.20: -Example of 2D Bezier curves generated by different number of control points.
• Efficient method for determining coordinate positions along a Bezier curve can be set up using recursive
calculation
• For example successive binomial coefficients can be calculated as
𝑛−𝑘+1
𝐶(𝑛, 𝑘) = 𝐶(𝑛, 𝑘 − 1) 𝑛≥𝑘
𝑘
∑ 𝐵𝐸𝑍𝑘,𝑛(𝑢) = 1
𝑘=0
• So any curve position is simply the weighted sum of the control point positions.
• Bezier curve smoothly follows the control points without erratic oscillations.
15
Unit-4 – 3D Concept & Object Representation
P3
P2
P4
P1
P0=P5
Fig. 4.21: -A closed Bezier Curve generated by specifying the first and last control points at the same
location.
• If we specify multiple control point at same position it will get more weight and curve is pull towards
that position.
P3
P1=P2
P0
P4
Fig. 4.22: -A Bezier curve can be made to pass closer to a given coordinate position by assigning multiple
control point at that position.
• Bezier curve can be fitted for any number of control points but it requires higher order polynomial
calculation.
• Complicated Bezier curve can be generated by dividing whole curve into several lower order polynomial
curves. So we can get better control over the shape of small region.
• Since Bezier curve passes through first and last control point it is easy to join two curve sections with
zero order parametric continuity (C0).
• For first order continuity we put end point of first curve and start point of second curve at same position
and last two points of first curve and first two point of second curve is collinear. And second control
point of second curve is at position
𝑝𝑛 + (𝑝𝑛 − 𝑝𝑛−1)
• So that control points are equally spaced.
16
Unit-4 – 3D Concept & Object Representation
Fig. 4.23: -Zero and first order continuous curve by putting control point at proper place.
• Similarly for second order continuity the third control point of second curve in terms of position of the
last three control points of first curve section as
𝑝𝑛−2 + 4(𝑝𝑛 − 𝑝𝑛−1)
• C2 continuity can be unnecessary restrictive especially for cubic curve we left only one control point for
adjust the shape of the curve.
17
Unit-4 – 3D Concept & Object Representation
• The form of blending functions determines how control points affect the shape of the curve for values of
parameter u over the range from 0 to 1.
At u = 0 𝐵𝐸𝑍0,3(𝑢) is only nonzero blending function with values 1.
At u = 1 𝐵𝐸𝑍3,3(𝑢) is only nonzero blending function with values 1.
• So the cubic Bezier curve is always pass through p0 and p3.
• Other blending function is affecting the shape of the curve in intermediate values of parameter u.
• 𝐵𝐸𝑍1,3(𝑢) is maximum at 𝑢 = 1⁄3and 𝐵𝐸𝑍2,3(𝑢) is maximum at 𝑢 = 2⁄3
• Blending function is always nonzero over the entire range of u so it is not allowed for local control of the
curve shape.
• At end point positions parametric first order derivatives are :
𝑝′(0) = 3(𝑝1 − 𝑝0)
𝑝′(1) = 3(𝑝3 − 𝑝2)
• And second order parametric derivatives are.
𝑝′′(0) = 6(𝑝0 − 2𝑝1 + 𝑝2)
𝑝′′(1) = 6(𝑝1 − 2𝑝2 + 𝑝3)
• This expression can be used to construct piecewise curve with C1 and C2 continuity.
• Now we represent polynomial expression for blending function in matrix form:
𝑝0
𝑝1
𝑝(𝑢) = [𝑢3 𝑢2 𝑢 1] ∙ 𝑀𝐵𝐸𝑍 ∙
[𝑝 ]
2
𝑝3
−1 3 −3 1
3 −6 3 0
𝑀𝐵𝐸𝑍 = [ ]
−3 3 0 0
1 0 0 0
• We can add additional parameter like tension and bias as we did with the interpolating spline.
Bezier Surfaces
• Two sets of orthogonal Bezier curves can be used to design an object surface by an input mesh of control
points.
• By taking Cartesian product of Bezier blending function we obtain parametric vector function as:
𝑚 𝑛
𝑝(𝑢, 𝑣) = ∑ ∑ 𝑝𝑗,𝑘𝐵𝐸𝑍𝑗,𝑚(𝑣)𝐵𝐸𝑍𝑘,𝑛(𝑢)
𝑗=0 𝑘=0
• 𝑝𝑗,𝑘 Specifying the location of the (m+1) by (n+1) control points.
• Figure below shows Bezier surfaces plot, control points are connected by dashed line and curve is
represented by solid lines.
Fig. 4.25: -Bezier surfaces constructed for (a) m=3, n=3, and (b) m=4, n=4. Dashed line connects the
control points.
18
Unit-4 – 3D Concept & Object Representation
• Each curve of constant u is plotted by varying v over interval 0 to 1. And similarly we can plot for
constant v.
• Bezier surfaces have same properties as Bezier curve, so it can be used in interactive design application.
• For each surface patch we first select mesh of control point XY and then select elevation in Z direction.
• We can put two or more surfaces together and form required surfaces using method similar to curve
section joining with continuity C0, C1, and C2 as per need.
B-Spline Curves
• General expression for B-Spline curve in terms of blending function is given by:
𝑛
19
Unit-4 – 3D Concept & Object Representation
• For any u in between 𝑢𝑑−1 to 𝑢𝑛+1, sum of all blending function is 1 i.e. ∑𝑘=0
𝑛 𝐵𝑘,𝑑(𝑢) = 1
• There are three general classification for knot vectors:
o Uniform
o Open uniform
o Non uniform
• Matrix formulation for a cubic periodic B-Splines with the four control points can then be written as
𝑝0
𝑝1
𝑝(𝑢) = [𝑢3 𝑢2 𝑢 1] ∙ 𝑀𝐵 ∙
[𝑝 ]
2
𝑝3
20
Unit-4 – 3D Concept & Object Representation
Where
−1 3 −3 1
1 3 −6 3 0
𝑀𝐵 = [ ]
6 −3 0 3 0
1 4 1 0
• We can also modify the B-Spline equation to include a tension parameter t.
• The periodic cubic B-Spline with tension matrix then has the form:
−𝑡 12 − 9𝑡 9𝑡 − 12 𝑡
1 3𝑡 12𝑡 − 18 18 − 15𝑡 0
𝑀𝐵𝑡 = [ ]
6 −3𝑡 0 3𝑡 0
𝑡 6 − 2𝑡 𝑡 0
When t = 1 𝑀𝐵𝑡 = 𝑀𝐵
• We can obtain cubic B-Spline blending function for parametric range from 0 to 1 by converting matrix
representation
1 into polynomial form for t = 1 we have
𝐵 ( ) 3
0,3 𝑢
= (1 − 𝑢)
6
1
𝐵1,3 (𝑢) = (3𝑢3 − 6𝑢2 + 4)
6
1
𝐵2,3 (𝑢) = (−3𝑢3 + 3𝑢2 + 3𝑢 + 1)
6
1
𝐵3,3 (𝑢) = 𝑢3
6
21
Unit-4 – 3D Concept & Object Representation
• Multiple knot value also reduces continuity by 1 for each repeat of particular value.
• We can solve non uniform B-Spline using similar method as we used in uniform B-Spline.
• For set of n+1 control point we set degree d and knot values.
• Then using the recurrence relations we can obtain blending function or evaluate curve position directly
for display of the curve.
B-Spline Surfaces
• B-Spline surface formation is also similar to Bezier splines orthogonal set of curves are used and for
connecting two surface we use same method which is used in Bezier surfaces.
• Vector equation of B-Spline surface is given by cartesion product of B-Spline blending functions:
𝑛1 𝑛2
𝑝(𝑢, 𝑣) = ∑ ∑ 𝑝𝑘1,𝑘2𝐵𝑘1,𝑑1(𝑢)𝐵𝑘2,𝑑2(𝑣)
𝑘1=0 𝑘2=0
• Where 𝑝𝑘1,𝑘2 specify control point position.
• It has same properties as B-Spline curve.
22
Unit-5 – 3D Transformation and Viewing
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).
𝑃′ = 𝑇 ∙ 𝑃
𝑥, 1 0 0 𝑡𝑥 𝑥
𝑦′ 0 1 0 𝑡𝑦 𝑦
[𝑧, ] = [ ]∙
0 0 1 𝑡𝑧 [𝑧]
1 0 0 0 1 1
𝑥′, 1 0 0 10 10
𝑦 0 1 0 20 10
[ ]=[ ]∙[ ]
𝑧, 0 0 1 5 10
1 0 0 0 1 1
𝑥, 20
′ 30
[𝑦
𝑧 ,] = [ ]
15
1 1
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
1
Unit-5 – 3D Transformation and Viewing
Coordinate-Axes Rotations
Y Y Y
X X X
Z Z Z
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:
𝑷′ = 𝑹𝒙(𝜽) ∙ 𝑷
𝒙, 𝟏 𝟎 𝟎 𝟎 𝒙
𝒚′ 𝒚
= 𝟎 𝐜𝐨𝐬 𝜽 − 𝐬𝐢𝐧 𝜽 𝟎] ∙ [ ]
[ 𝒛, ] [
𝟎 𝐬𝐢𝐧 𝜽 𝐜𝐨𝐬 𝜽 𝟎 𝒛
𝟏 𝟎 𝟎 𝟎 𝟏 𝟏
2
Unit-5 – 3D Transformation and Viewing
• 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.
𝑃′ = 𝑅𝑧(𝜃) ∙ 𝑃
𝑥, cos 𝜃 − sin 𝜃 0 0 𝑥
𝑦′ sin 𝜃 cos 𝜃 0 0 𝑦
= ]∙
[ 𝑧, ] [ 0 0 1 0 [𝑧]
1 0 0 0 1 1
𝑥′, cos 90 − sin 90 0 0 𝑥
𝑦 sin 90 cos 90 0 0 𝑦
= ]∙
[ 𝑧, ] [ 0 0 1 0 [𝑧]
1 0 0 0 1 1
𝑥 , 0 −1 0 0 5
′
𝑦 1 0 0 0 5
[ ]=[ ]∙[ ]
𝑧, 0 0 1 0 5
1 0 0 0 1 1
𝑥, −5
𝑦′ 5
[𝑧, ] = [ ]
5
1 1
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:
𝑷′ = 𝑻−𝟏 ∙ 𝑹(𝜽) ∙ 𝑻 ∙ 𝑷
3
Unit-5 – 3D Transformation and Viewing
• 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
u’ u
α
X
uz
4
Unit-5 – 3D Transformation and Viewing
𝒖′ ∙ 𝒖 𝒛 (𝟎, 𝒃, 𝒄)(𝟎, 𝟎, 𝟏) 𝒄
𝐜𝐨𝐬 𝑎 = = = 𝒘𝒉𝒆𝒓𝒆 𝒅 = √𝒃𝟐 + 𝒄𝟐
|𝒖′||𝒖𝒛| √𝒃𝟐 + 𝒄𝟐 𝒅
And
𝒖′ × 𝒖𝒛 = 𝒖𝒙|𝒖′||𝒖𝒛| 𝐬𝐢𝐧 𝑎 = 𝒖𝒙 ∙ 𝒃
𝒖𝒙|𝒖′||𝒖𝒛| 𝐬𝐢𝐧 𝑎 = 𝒖𝒙 ∙ 𝒃
Comparing magnitude
|𝒖′||𝒖𝒛| 𝐬𝐢𝐧 𝑎 = 𝒃
√𝒃𝟐 + 𝒄𝟐 ∙ (𝟏) 𝐬𝐢𝐧 𝑎 = 𝒃
𝒅 𝐬𝐢𝐧 𝑎 = 𝒃
𝒃
𝐬𝐢𝐧 𝑎 =
𝒅
• Now we have 𝐬𝐢𝐧 𝑎 and 𝐜𝐨𝐬 𝑎 so we will write matrix for rotation about X-axis.
𝟏 𝟎 𝟎 𝟎
𝟎 𝐜𝐨𝐬 𝑎 − 𝐬𝐢𝐧 𝑎 𝟎
𝑹𝒙 (𝑎) = [ ]
𝟎 𝐬𝐢𝐧 𝑎 𝐜𝐨𝐬 𝑎 𝟎
𝟎 𝟎 𝟎 𝟏
𝟏 𝟎 𝟎 𝟎
𝖥 𝒄 𝒃 1
I𝟎 − 𝟎l
𝒅 𝒅
𝑹𝒙(𝑎) = I l
I𝟎 𝒃 𝒄 l
I 𝒅 𝒅 𝟎l
[𝟎 𝟎 𝟎 𝟏]
• After performing above rotation ‘u’ will rotated into ‘u’’’ in XZ-plane with coordinates (a, 0, √(b2+c2)). 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’’
5
Unit-5 – 3D Transformation and Viewing
(𝟏) 𝐬𝐢𝐧 𝖰 = − 𝒂
𝐬𝐢𝐧 𝖰 = − 𝒂
• 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.
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.
Scaling
6
Unit-5 – 3D Transformation and Viewing
𝒙, 𝒔𝒙 𝟎 𝟎 𝟎 𝒙
[ ,] [ 𝟎
𝒚 ′ 𝒔 𝟎 𝟎 ∙ 𝒚
𝒛 = 𝟎 𝟎𝒚 𝒔 ] [ ]
𝒛 𝟎 𝒛
𝟏 𝟎 𝟎 𝟎 𝟏 𝟏
• Example: - Scale the line AB with coordinates (10,20,10) and (20,30,30) respectively with scale factor
S(3,2,4).
𝑃′ = 𝑆 ∙ 𝑃
𝑥, 𝑠𝑥 0 0 0 𝑥
𝑦 ′
[ ] [ 0 𝑠 0 0 𝑦
= 𝑦 ] ∙
𝑧, 0 0 𝑠𝑧 0 [𝑧]
1 0 0 0 1 1
𝐴 ′ 𝐵𝑥 ′ 3 0 0 0 10 20
𝖥 𝑥 1
𝐴
I 𝑦
′ 𝐵 ′
𝑦l
=[ 0 2 0 0 ]∙[ 20 30]
′
I𝐴𝑧 𝐵𝑧 l ′ 0 0 4 0 10 30
[ 1 1] 0 0 0 1 1 1
𝐴𝑥 ′ 𝐵𝑥 ′ 30 60
𝖥 1
𝐴
I 𝑦
′ 𝐵 ′
𝑦l 40 60
=[ ]
′
I𝐴𝑧 𝐵𝑧 l ′ 40 120
[ 1 1] 1 1
Final coordinates after scaling are A, (30, 40, 40) and B’ (60, 60, 120).
X
Fixed Point
7
Unit-5 – 3D Transformation and Viewing
𝖥𝒔𝒙 𝟎 𝟎 (𝟏 − 𝒔𝒙)𝒙𝒇1
′ 𝟎 𝒔𝒚 𝟎 (𝟏 − 𝒔𝒚)𝒚𝒇
𝑷 =I l∙𝑷
I𝟎 𝟎 𝒔𝒛 (𝟏 − 𝒔𝒛)𝒛𝒇 l
[𝟎 𝟎 𝟎 𝟏 ]
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
𝟏 𝟎 𝒂 𝟎
𝟎 𝟏 𝒃 𝟎
𝑺𝑯 = [ ]
𝒛
𝟎 𝟎 𝟏 𝟎
𝟎 𝟎 𝟎 𝟏
• Similarly Shear matrix for X-axis is.
𝟏 𝟎 𝟎 𝟎
𝒂 𝟏 𝟎 𝟎
𝑺𝑯 = [ ]
𝒙
𝒃 𝟎 𝟏 𝟎
𝟎 𝟎 𝟎 𝟏
• Similarly Shear matrix for X-axis is.
𝟏 𝒂 𝟎 𝟎
𝟎 𝟏 𝟎 𝟎
𝑺𝑯 = [ ]
𝒚
𝟎 𝒃 𝟏 𝟎
𝟎 𝟎 𝟎 𝟏
8
Unit-5 – 3D Transformation and Viewing
Viewing Pipeline
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.
• Similarly we can specify viewing coordinate in ordinary direction.
Fig. 5.9: -A right handed viewing coordinate system, with axes Xv, Yv, and Zv, relative to a world-
coordinate scene.
9
Unit-5 – 3D Transformation and Viewing
• 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. 5.10: -Viewing scene from different direction with a fixed view-reference point.
Fig. 5.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
10
Unit-5 – 3D Transformation and Viewing
• 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:
1 0 0 −𝑥0
• 𝑇 = [0 1 0 −𝑦0]
0 0 1 −𝑧0
0 0 0 1
• 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:
𝑢1 𝑢2 𝑢3 0
𝑣 𝑣2 𝑣3 0
𝑅=[ 1 ]
𝑛1 𝑛2 𝑛3 0
0 0 0 1
• 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.
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.
• Lets discuss each one.
Parallel Projections
View
Plane
P1
P1’
P2
P2’
11
Unit-5 – 3D Transformation and Viewing
• 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.
View Plane
Projection Line
12
Unit-5 – 3D Transformation and Viewing
(X,Y,Z) Yv
(X,Y)
Xv
Zv
View Plane
Projection Line
(Xp, Yp)
(X,Y,Z)
αL
Φ
Xv
(X,Y)
Zv
13
Unit-5 – 3D Transformation and Viewing
𝒙𝒑 = 𝒙 + 𝑳 𝐜𝐨𝐬 ∅
𝒚𝒑 = 𝒚 + 𝑳 𝐬𝐢𝐧 ∅
• 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.
Perspective Projection
View
Plane
P1
P1’
P2 P2’ Projection
Reference
point
P=(x,y,z)
(xp,yp,zvp)
zvp zprp zv
View
Plane
14
Unit-5 – 3D Transformation and Viewing
𝒙′ = 𝒙 − 𝒙𝒖
𝒚′ = 𝒚 − 𝒚𝒖
𝒛′ = 𝒛 − (𝒛 − 𝒛𝒑𝒓𝒑)𝒖
• 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 of z’.
𝒛′ = 𝒛 − (𝒛 − 𝒛𝒑𝒓𝒑)𝒖
𝒛𝒗𝒑 = 𝒛 − (𝒛 − 𝒛𝒑𝒓𝒑)𝒖
𝒛𝒗𝒑 − 𝒛
𝒖=
𝒛𝒑𝒓𝒑 − 𝒛
• 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.
𝒙𝒉
𝒚𝒉 𝖥𝟏𝟎 𝟎𝟏
𝟎
𝟎
𝟎
𝟎 1 𝒚
𝒙
[𝒛 ] = I𝟎 𝟎 − l
𝒛𝒗𝒑(𝒛𝒑𝒓𝒑⁄𝒅𝒑) ∙ [𝒛]
𝒉 I l
𝒛𝒗𝒑⁄𝒅𝒑
𝒉 [𝟎 𝟎 − 𝒛𝒑𝒓𝒑⁄𝒅𝒑 ] 𝟏
𝟏⁄𝒅𝒑
• 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.
15
Unit-5 – 3D Transformation and Viewing
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)
16
Unit-5 – 3D Transformation and Viewing
N Zv
Window
View Vp
Volume
Window N Zv
View V’p
Volume
17
Unit-5 – 3D Transformation and Viewing
• Thus, we have the general parallel-projection matrix in terms of the elements of the projection vector as
𝖥𝟏 𝒙 𝟎
−𝒑 𝟎1
𝒑𝒛
I −𝒑𝒚 l
𝑴 = I𝟎 𝟏 𝟎l
𝒑𝒂𝒓𝒂𝒍𝒍𝒆𝒍
I 𝒑𝒛 l
I𝟎 𝟎 𝟏 𝟎l
[𝟎 𝟎 𝟎 𝟏]
• For an orthographic parallel projection, px = py = 0, and is the identity matrix.
Frustum
Centerline
Zv
View Volume
View Plane
Center of Window
Frustum
Centerline
(X’’, Y’’, Z’’)
Center of Window
18
Unit-5 – 3D Transformation and Viewing
• 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:
−𝒙𝒑𝒓𝒑 𝒙𝒑𝒓𝒑𝒛𝒗𝒑
𝖥𝟏 𝟎 𝒛 1
I 𝒑𝒓𝒑 − 𝒛 𝒗𝒑 𝒛 𝒑𝒓𝒑 − 𝒛 𝒗𝒑 l
I𝟎 𝟏 −𝒚𝒑𝒓𝒑 𝒚𝒑𝒓𝒑𝒛𝒗𝒑 l
𝑴𝒔𝒄𝒂𝒍𝒆 = I 𝒛𝒑𝒓𝒑 − 𝒛𝒗𝒑 𝒛𝒑𝒓𝒑 − 𝒛𝒗𝒑l
I𝟎 𝟎 𝟏 𝟎 l
I
−𝟏 𝒛𝒑𝒓𝒑 l
I𝟎 𝟎 [ l
𝒛𝒑𝒓𝒑 − 𝒛 𝒗𝒑 𝒛𝒑𝒓𝒑 − 𝒛 𝒗𝒑]
• Therefore the general perspective-projection transformation is obtained by equation:
𝑴𝒑𝒆𝒓𝒔𝒑𝒆𝒄𝒕𝒊𝒗𝒆 = 𝑴𝒔𝒄𝒂𝒍𝒆 ∙ 𝑴𝒔𝒉𝒆𝒂𝒓
19
Q1) Classification of visible surface detection algorithm
In the realistic graphics display, we have to identify those parts of a scene that
are visible from a chosen
viewing position. The various algorithms that are used for that are referred to
as Visible-surface detection methods or hidden-surface elimination
methods.
Back-face detection can identify all the hidden surfaces in a scene that
contain non-overlapping convex polyhedra.
Ax + By + Cz + D < 0
While determining whether a surface is back-face or front face, also consider
the viewing direction. The normal of the surface is given by :
N = (A, B, C)
A polygon is a back face if Vview.N > 0. But it should be kept in mind that after
application of the viewing transformation, viewer is looking down the negative
Z-axis. Therefore, a polygon is back face if :
Considering (a),
V.N = |V||N|Cos(angle)
if 0 <= angle 0 and V.N > 0
Hence, Back-face.
Considering (b),
V.N = |V||N|Cos(angle)
if 90 < angle <= 180, then
cos(angle) < 0 and V.N < 0
Hence, Front-face.
Limitations :
1) This method works fine for convex polyhedra, but not necessarily for
concave polyhedra.
2) This method can only be used on solid objects modeled as a polygon mesh.
Trivial cases are easily handled. Non trivial cases are divided into four equal
subwindows. The windows are again further subdivided using recursion until
all polygons classified trivial and non trivial.
Classification of Scheme
It divides or classifies polygons in four categories:
1. Inside surface
2. Outside surface
3. Overlapping surface
4. Surrounding surface
Algorithm :
As the z value i.e, the depth value at every place in the given
polygon is 3, on applying the algorithm, the result is:
Now, let’s change the z values. In the figure given below, the z
values goes from 0 to 3.
• Frame buffer
• Depth buffer
Calculation of depth :
As we know that the equation of the plane is :
ax + by + cz + d = 0, this implies
AX + BY + CZ + D = 0 implies
Z = (-AX - BY - D)/C ------------(1)
Let S1, S2, S3 are the surfaces. The surface closest to projection
plane is called visible surface. The computer would start
(arbitrarily) with surface 1 and put it’s value into the buffer. It
would do the same for the next surface. It would then check
each overlapping pixel and check to see which one is closer to
the viewer and then display the appropriate color. As at view-
plane position (x, y), surface S1 has the smallest depth from the
view plane, so it is visible at that position.
Points to remember :
1) Z buffer method does not require pre-sorting of polygons.
2) This method can be executed quickly even with many polygons.
3) This can be implemented in hardware to overcome the speed
problem.
4) No object to object comparison is required.
5) This method can be applied to non-polygonal objects.
6) Hardware implementation of this algorithm are available in some
graphics workstations.
7) The method is simple to use and does not require additional data
structure.
8) The z-value of a polygon can be calculated incrementally.
9) Cannot be applied on transparent surfaces i.e, it only deals with
opaque surfaces. For ex :
10) If only a few objects in the scene are to be rendered, then this
method is less attractive because of additional buffer and the overhead
involved in updating the buffer.
11) Wastage of time may occur because of drawing of hidden objects.
Traditional animation is a technique where each frame of an
animation is drawn by hand. This process is very time-consuming
and labor-intensive, but it can create beautiful and expressive
animation.
Traditional animation is a classic art form that has been used to create some
of the most beloved animated films of all time. Although computer
animation has become more popular in recent years, traditional animation
is still used today in some films and television shows.
O App
Q7) Describe Various Principles Of Traditional Animation
Animation is defined as a series of images rapidly changing to
create an illusion of movement. We replace the previous image
with a new image which is a little bit shifted. Animation Industry
is having a huge market nowadays. To make an efficacious
animation there are some principles to be followed.
Principle of Animation:
2) Anticipation:
Anticipation works on action.Animation has broadly divided into
3 phases:
1. Preparation phase
2. Movement phase
3. Finish
3. Arcs:
In Reality, humans and animals move in arcs.
Introducing the concept of arcs will increase the
realism. This principle of animation helps us to
implement the realism through projectile motion
also. For Example, The movement of the hand
of bowler comes under projectile motion while
doing bowling.
5. Appeal:
Animation should be appealing to the audience and
must be easy to understand. The syntax or font style
used should be easily understood and appealing to the
audience. Lack of symmetry and complicated design of
character should be avoided.
6. Timing: Velocity with which object is moving effects
animation a lot. The speed should be handled with care
in case of animation. For Example, An fast-moving
object can show an energetic person while a slow-
moving object can symbolize a lethargic person. The
number of frames used in a slowly moving object is less
as compared to the fast-moving object.
7. 3D Effect:
By giving 3D effects we can make our
animation more convincing and effective.
In 3D Effect, we convert our object in a 3-
dimensional plane i.e., X-Y-Z plane which
improves the realism of the object. For
Example, a square can give a 2D effect but
cube can give a 3D effect which appears
more realistic.
8. Exaggeration:
10.Secondary Action:
Secondary actions are more important than
primary action as they represent the animation as
a whole. Secondary actions support the primary
or main idea. For Example, A person drinking a
hot tea, then his facial expressions, movement of
hands, etc comes under the secondary actions.
11.Follow Through:
It refers to the action which continues to move
even after the completion of action. This type of
action helps in the generation of more idealistic
animations. For Example: Even after throwing a
ball, the movement of hands continues.
12.Overlap:
It deals with the nature in which before ending
the first action, the second action starts. For
Example: Consider a situation when we are
drinking Tea from the right hand and holding
a sandwich in the left hand. While drinking a
tea, our left-hand start showing movement
towards the mouth which shows the
interference of the second action before the
end of the first action.