SlideShare a Scribd company logo
1 of 78
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
PAPER NAME: COMPUTER GRAPHICS
PAPER CODE: BCA 303
CLASS: BCA Vth Semester
UNIT-I Graphics Display Devices
• Frame Buffer – a region of memory sufficiently large to hold all of the
pixel values for the display
Block
Diagram
of
Computer
with
Raster
Display
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)2
Graphics Display Devices - cont
• How each pixel value in the frame buffer
is sent to the right place on the display
surface
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)3
Graphics Devices – cont
• Each pixel has a 2D address (x,y)
– For each address (x,y) there is a specific memory
location that holds the value of the pixel (I.e.
mem[136][252])
– The scan controller sends the logical address (136,
252) to the frame buffer, which emits the value
mem[136][252]
– The value mem[136][252] is converted to a
corresponding intensity or color in the conversion
circuit, and that intensity or color is sent to the
proper physical position, (136, 252), on the display
surfaceChanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)4
Graphics Devices – cont
• Each pixel has a 2D address (x,y)
– For each address (x,y) there is a specific memory
location that holds the value of the pixel (I.e.
mem[136][252])
– The scan controller sends the logical address (136,
252) to the frame buffer, which emits the value
mem[136][252]
– The value mem[136][252] is converted to a
corresponding intensity or color in the conversion
circuit, and that intensity or color is sent to the
proper physical position, (136, 252), on the display
surfaceChanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)5
Graphics Devices – cont
• Each pixel has a 2D address (x,y)
– For each address (x,y) there is a specific memory
location that holds the value of the pixel (I.e.
mem[136][252])
– The scan controller sends the logical address (136,
252) to the frame buffer, which emits the value
mem[136][252]
– The value mem[136][252] is converted to a
corresponding intensity or color in the conversion
circuit, and that intensity or color is sent to the
proper physical position, (136, 252), on the display
surfaceChanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)6
Graphics Devices – cont
• Each pixel has a 2D address (x,y)
– For each address (x,y) there is a specific memory
location that holds the value of the pixel (I.e.
mem[136][252])
– The scan controller sends the logical address (136,
252) to the frame buffer, which emits the value
mem[136][252]
– The value mem[136][252] is converted to a
corresponding intensity or color in the conversion
circuit, and that intensity or color is sent to the
proper physical position, (136, 252), on the display
surfaceChanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)7
Graphics Devices – cont
• Each pixel has a 2D address (x,y)
– For each address (x,y) there is a specific memory
location that holds the value of the pixel (I.e.
mem[136][252])
– The scan controller sends the logical address (136,
252) to the frame buffer, which emits the value
mem[136][252]
– The value mem[136][252] is converted to a
corresponding intensity or color in the conversion
circuit, and that intensity or color is sent to the
proper physical position, (136, 252), on the display
surfaceChanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)8
Scan Converting Lines
• Line Drawing
– Draw a line on a raster screen between 2
points
– What’s wrong with the statement of the problem?
• It does not say anything about which pts are
allowed as end pts
• It does not give aclear meaning to“draw”
• It does not saywhat constitutes a“line”in the raster
world
• It does not say how to measure the success of the
proposed algorithm
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)9
Graphics Devices – cont
• Each pixel has a 2D address (x,y)
– For each address (x,y) there is a specific memory
location that holds the value of the pixel (I.e.
mem[136][252])
– The scan controller sends the logical address (136,
252) to the frame buffer, which emits the value
mem[136][252]
– The value mem[136][252] is converted to a
corresponding intensity or color in the conversion
circuit, and that intensity or color is sent to the
proper physical position, (136, 252), on the display
surfaceChanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia1)0
Scan Converting Lines - cont
• Problem Statement
– Given 2 points P and Q in the plane, both
with integer coordinates, determine which
pixels on a raster screen should be “on” in
order to make a picture of a unit-width line
segment starting at point P and ending at
point Q
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia1)1
Finding the next pixel
• Special Case:
– Horizontal Line:
• Draw pixel P and increment the x coordinate value by one
to get the next pixel.
– Vertical Line:
• Draw the pixel P and increment the y coordinate value by one
to
get the next pixel
– Diagonal Line:
• Draw the pixel P and increment both the x and y coordinate
values by one to get the next pixel
– What should we use in the general case?
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia1)2
Vertical Distance
• Why can we use the vertical
distance as a measure of which
point is closer?
– Because vertical distance is
proportional to the actual distance
– How do we show t
– Congruent Triangl
his
?
es
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia1)3
Vertical Distance – cont
• By similar triangles we can see that the
true distances to the line (in blue) are
directly proportional to the vertical
distances to the line (in black) for each
point.
• Therefore the point with the smaller
vertical distance to the line is the
closest to the line
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia1)4
Strategy 1 – IncrementalAlgorithm
• The Basic Algorithm
– Find the equation of the line that
connects the 2 points P and Q
– Starting with the leftmost point P,
increment where A
=
xi
by 1 to calculate
slope, and B = y
intercept
– Intensify the pixel at
yi  Axi  B– This computation selects the closest pixel,
the pixel whose distance to the “true” line is
smallest
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia1)5
Strategy 1 – IncrementalAlgorithm
• The Incremental Algorithm
– Each iteration requires a floating-
point multiplication therefore,
modify
Yi  1  Axi  1  B  Axi  x B  yi
– If , then– Thusx,a1unit chayni 
g1
einyi
xchAanges y by
slope A, which is the slope of the line
– At each step, we make incremental
calculations based on the preceding step
to find the next y value
 Ax
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia1)6
Strategy 1 – Incremental Algo
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia1)7
Example Code
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia1)8
Problem with the IncrementalAlgorithm
• Rounding integers takes time
• Real variables have limited precision,
summing an inexact slope (A) repetitively
introduces a cumulative error buildup
• Variables y and A must be a real or
fractional binary because the slope is a
fraction
– Special case needed for vertical lines
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia1)9
Strategy 2 – Midpoint LineAlgorithm
• Assumethat the line’s slope is shallow and positive ( 0<
slope < 1); other slopes can be handled by suitable
reflections about the principle axes
• Call the lower left
endpoint
and the
upperright
endpoint
x0, y0
 • Assume that we hxa1
v,eyju1
st selected the pixel P at
• Next, we must choose between the pixel to the
right (pixel E), or one right and one up (pixel
NE)
• Let Q be the intersection point of the line being
scan- converted with the grid line
xp, yp 
Chanderprabhu Jain College oxf HighxeprStu1dies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia2)0
Strategy 2 – Midpoint Line Algorithm
1/1/2000
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia2)1
Strategy 2 – Midpoint LineAlgorithm
• The line passes between E and NE
• The point that is closer to the intersection point Q
must be chosen
• Observe on which side of the line the midpoint M lies:
– E is closer to the line if the midpoint lies above the line (I.e.
the line crosses the bottom half)
– NE is closer to the line if the midpoint lies below the line, I.e., the
line
crosses the top half
• The error, thevertical distance between the chosen pixel
and the actual line is always <= ½
• The algorithm chooses NE as the next pixel for the line
shown
• Now, find a way to calculate on which side of the line the
midpoint lies
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia2)2
The Line
• The line equation as a function f(x):
– f(x) = A*x + B = dy/dx * x + B
• Line equation as an implicit function:
– F(x,y) = a * x + b * y + c = 0 for coefficients a, b, c where a, b !=
0; from above, y *dx = dy*x + B*dx, so a = dy, b = -dx,
c=B *dx, a>0 for y(0) < y(1)
• Properties (proof by the case analysis):
–
–
when any point M is on the line
when any point M is above the
line– F(xm, ym)  0 when any point M is below the line
– OurFde(xcimsi,oynmw)illb0ebased on the value of the function at the
midpoint
M aFt (xm, ym) 0
2
1x 1, y 
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprpastha Universitpyand Approved by Govt of NCT of Delhi & Bar Council of India2)3
Decision Variable
• Decision Variable d:
to see
where
• How to update d:
– On the basis of picking E or NE, figure out the
location of the M for that pixel, and the
corresponding value of d for
the next grid line
– We only need the sign of F (xp 1, yp 
1
2)the line lies, and then pick the nearest
pixel
– D  F (xp 1, yp 1
2)
• If d > 0 choose pixel NE
• If d < 0 choose pixel E
• If d = 0 choose either one consistently
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia2)4
Example Code
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia2)5
Rotation About the Origin
To rotate a line or polygon, we must rotate
each of its vertices.
To rotate point (x1,y1) to point (x2,y2) we
observe:
From the illustration we know that:
sin (A + B) = y2/r cos (A + B) = x2/r
sin A= y1/r cos A =x1/r
x-axis
(x1,y1)
(x2,y2)
A
B
r
(0,0)
y-axis
UNIT-II 2-D TRANSFORMATIONS
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Rotation About the Origin
From the double angle formulas: sin (A + B) =
sinAcosB + cosAsinB
cos (A + B)= cosAcosB -
sinAsinB
y2/r = (y1/r)cosB +Substituting:
(x1/r)sinB
Therefore: y.2= yP11cosB+ x1sinB
We have
y1sinB
P2 = R
(y2) (sinB cosB) (y1)
(x2) (cosB -sinB) (x1)x2 = x1cosB -
=
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Translations
y( t )1( y )
P2 = (x1 + tx)
(y1 + ty)
Moving an object is called a translation. We translate a point by
adding to the x and y coordinates, respectively, the amount the
point should be shifted in the x and y directions. We translate an
object by translating each vertex in the object.
P2 = P1 + T
Ty
P1 = ( x1 ) T = ( tx )
Tx
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Scaling
Changing the size of an object is called a scale. We scale an object by
scaling the x and y coordinates of each vertex in the object.
P2 = .SP1
S = (sx
(0 sy)
0) P1 = ( x1 )
)( y1
P2 =(sxx1)
(syy1)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Homogeneous Coordinates
cos ø -sin ø 0
Rø = sin ø cos ø 0
0 0 1
Sx 0 0
S = 0 Sy 0
0 0 1
1 0 T
x
T = 0 1 T
y
0 0 1
Although the formulas we have shown are usually the most efficient way to
implement programs to do scales, rotations and translations, it is easier to use
matrix transformations to represent and manipulate them.
In order to represent a translation as a matrix operation we use 3 x 3 matrices
and pad our points to become 1 x 3 matrices.
(x)
Point P =(y)
(1)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Composite Transformations - Scaling
Given our three basic transformations we can create other
transformations.
Scaling with a fixed point
A problem with the scale transformation is that it also moves the
object being scaled.
Scale a line between (2, 1) (4,1) to twice its length.
(2 0 0)
(0 1 0)
(0 0 1)
(2 0 0)
(0 1 0)
(0 0 1)
=
=
Before
After
(2) (4)
(1) (1)
(1) (1)
(4) (8)
(1) (1)
(1) (1)
Chanderprabhu Jain Colle0ge 1of H2 ig3her4Stu5die6s &7 Sc8ho9olo10fLaw
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Composite Transforms - Scaling (cont.)
If we scale a line between (0, 1) (2,1) to twice its length, the left-
hand endpoint does not move.
=(2 0 0)
(0 1 0)
(0 0 1
)
(0 0 1) (1)
(2 0 0) (1) =
(0 1 0) (2)
(0,0) is known as a fixed point for the basic scaling transformation.
We can used composite transformations to create a scale
transformation with different fixed points.
0 1 2 3 4 5 6 7 8 9 10
Before
After
(1)
(1)
(0) (0)
(1)
(1)
(0)
(1)
(1)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Fixed Point Scaling
Scale by 2 with fixed point = (2,1)
• Translate the point (2,1) to the
origin
• Scale by 2
• Translate origin to point (2,1)
(1 0 2) (2 0 0) (1 0 -2) = (2 0 -2)
(0 1 1) (0 1 0) (0 1 -1) (0 1 0)
(0 0 1) (0 0 1) (0 0 1) (0 0 1)
(2 0 -2) =
(0 1
0)
(0 0
1) =
(2) (2)
(1) (1)
(2 0 -2)
(0 1 0) (1) (1)
(0 0 1) (4) (6)
(1) (1) 0 1 2 3 4 5 6 7 8 9 10
Before
After
Chande(r1p)rabh(u1J)ainCollege of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
More Fixed Point Scaling
Scale by 2 with fixed point = (3,1)
• Translate the point (3,1) to the origin
• Scale by 2
• Translate origin to point (3,1)
(1 0 3) (2 0 0) (1 0 -3) = (2 0-3)
(0 1 1) (0 1 0) (0 1 -1) (0 1 0)
(0 0 1) (0 0 1) (0 0 1) (0 0 1)
(2 0 -3)
(0 1
0)
(0 0
1)
=
(2 0 -3)
(0 1
0)
(0 0
1)
=
0 1 2 3 4 5 6 7 8 9 10
Before
After
(2) (1)
(1) (1)
(1) (1)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Shears
Original
Data
y
Shear
x
Shear
1 0 0 1 b 0
a 1 0 0 1 0
0 0 1 0 0 1
GRAPHICS --> x shear --> GRAPHICS
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Reflections
Reflection about the y-axis Reflection about the x-axis
-1 0 0 1 0 0
0 1 0 0 -1 0
0 0 1 0 0 1
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
More Reflections
Reflection about the
origin
Reflection about the line
y=x
-1 0 0 0 1 0
0 -1 0 1 0 0
0 0 1 0 0 1
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
UNIT-III
SOLID MODELING
UNIT-III SOLID MODELING
Start with these four, three-view drawings – Parts 1, 2, 3, 4 below and project
all points around to show alignment of one object.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Part 1 - Extrude front view (.75) inches to finish. Why front view ? Because
it shows the most of the object in solid format, and all I had to do was to add
depth onto the object. The width and height already exist. With width and
height given in front view just add depth as shown(.75).
TOP
FRONT RT. SIDE
EXTRUDE FRONT VIEW .75 INCHES TO FINISH.
WHY FRONT VIEW? BECAUSE IT SHOWS THE
MOST OF OBJECT IN SOLID FORMAT, AND ALL I
HAD TO DO WAS TO ADD DEPTH ONTO THE
OBJECT THAT ALREADY HAD WIDTH & HEIGHT.
0.75
0.75
TOP
FRONT RT. SIDE
WIDTH
DEPTH
TO FINISH OBJECT PLACE DEPTH ON
TO THE WIDTH AND HEIGHT ALREADY
GIVEN IN FRONT VIEW.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Part 2 - From the top choose this part and with a polyline extrude it (1.5)
inches by placing the height onto the depth. Move it, align it to midpoint, and
union it to form one part.
FRONT RT. SIDE
1
TOP2
From the top choose this part and with a
polyline line extrude it 1.5 inches by
placing the height on depth
Move it, align it to
midpoint and union
it to form one part.
You can do this many ways
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Part 3 - What view would you pick to turn this drawing into parametricsolid?
(front view)
RT. SIDE
TOP
Part 3 - What view would you pick to make a parametric solid? .
You only need one move. Hint - place the height onto the
width.
1.00
2.50
1.00
FRO
1.00
NT
1.00
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Part 4 - What part best describes this object? (1 of right side view) The command you
use is extrude. What second best part would you pick? (2 of right side view) Then also
extrude. Now move number 1 to midpoint of number 2 midpoint and union.
FRONT
RT. SIDE
PART 4 What 2 Parts would best describe the object?
The command you would use is extrude. What second
part would you pick? Then also extrude. Now move to
midpoint and union it.
2.00
1
1.50
2
If you picked 1 and 2 you are right.
0.50
TOP 1.00
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Parts 1- 4 extruded & colored
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
UNT in partnership with TEA. Copyright ©. All rights reserved.
Drawing 2
See if you can turn these three-view drawings into solids.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Drawing 2
Lets start with top view (shows most overall shape). Extrude up (.48) inch and
place in two (.25) inch holes and subtract out the space. Place to side. Extrude
back part (2.13) inches. Move to side. Extrude part 3 back (1.50) of a inch, and
move to side. Rotate part 2 and part 3 parallel to part 1 position and stack them
on top to finish object, as shown in part 5.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Drawing 2 as Solid Model
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Drawing 3 – three-view
Copy all drawings and insert into CAD,
then shade these to get better picture.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Drawing 3
Three parts - red trace in a polyline for the overall shape and extrude down (.50)
inches. Second, place in a (.25) hole and subtract out hole. Yellow draw in with a
polyline for its overall shape and extrude it (.50) of a inch. Part magenta polyline in
over shape and extrude back (.75). Place in red parallel top of yellow (as shown)
place in magenta to the midpoint of yellow (as shown) and move to right side.
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Drawing 3 as Solid Model
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Drawing 4
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Drawing 4 as Solid Model
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
Chanderprabhu Jain College of Higher Studies & School of Law
Plot No. OCF, Sector A-8, Narela, New Delhi – 110040
(Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India)
UNIT-IV
HIDDEN SURFACE
REMOVAL
UNIT-IV HIDDEN SURFACE REMOVAL(Visibility)
• Assumption: All polygons are opaque
• What polygons are visible with respect to your viewfrustum?
 Outside: View Frustum Clipping
Remove polygons outside of the view volume
For example, Liang-Barsky 3D Clipping
 Inside: Hidden Surface Removal
Backface culling
Polygons facing away from the viewer
Occlusion
Polygons farther away are obscured by closer polygons
Full or partially occluded portions
• Why should we remove these polygons?
Avoid unnecessary expensive operations on these polygonslater
No Lines Removed
Hidden Lines Removed
Hidden Surfaces Removed
Occlusion: Full, Partial, None
Full Partial None
• The rectangle is closer than the triangle
• Should appear in front of the triangle
Backface Culling
• Avoid drawing polygons facing away from the viewer
 Front-facing polygons occlude these polygons in a closedpolyhedron
• Test if a polygon is front- or back-facing?
front-facing
back-facing
Ideas?
Detecting Back-face Polygons
• The polygon normal of a …
front-facing polygon points towards the viewer
back-facing polygon points away from the viewer
If (n  v) > 0  “back-face”
If (n  v) ≤ 0  “front-face”
v = view vector
• Eye-space test … EASY!
“back-face” if nz <0
• glCullFace(GL_BACK)
back
front
Polygon Normals
• Let polygon vertices v0, v1, v2,..., vn - 1 be in counterclockwise
order and co-planar
• Calculate normal with cross product:
n = (v1 - v0) X (vn - 1 - v0)
• Normalize to unit vector with n/║n║
v0
v1
v2
v4
n
v3
Normal Direction
• Vertices counterclockwise  Front-facing
• Vertices clockwise  Back-facing
0
1
2
0
2
1
Front facing Back facing
Painter’s Algorithm(1)
• Assumption: Later projected polygons overwrite earlier projectedpolygons
Graphics Pipeline
1 12 23 3
Oops! The red polygon
Should be obscured by
the blue polygon
Painter’s Algorithm(2)
• Main Idea
 A painter creates a pictureby
drawing background scene
elemens before foreground
ones
• Requirements
 Draw polygons in back-to-
front order
 Need to sort the polygons by
depth order to get a correct
image
from Shirley
Painter’s Algorithm(3)
• Sort by the depth of each polygon
Graphics Pipeline
1 12 23 3
depth
Painter’s Algorithm(4)
• Compute zmin ranges for eachpolygon
• Project polygons with furthest zmin first
(z) depth
zmin
zmin
zmin
zmin
Painter’s Algorithm(5)
• Problem: Can you get a total sorting?
zmin
zmin
zmin
zmin
Correct?
Painter’s Algorithm(6)
• Cyclic Overlap
 How do we sort these three polygons?
• Sorting is nontrivial
 Split polygons in order to get a totalordering
 Not easy to do in general
Visibility
• How do we ensure that closer polygons overwrite further ones ingeneral?
Z-Buffer
• Depth buffer (Z-Buffer)
A secondary image buffer that holds depth values
Same pixel resolution as the color buffer
Why is it called a Z-Buffer?
After eye space, depth is simply the z-coordinate
• Sorting is done at the pixel level
Rule: Only draw a polygon at a pixel if it is closer than a
polygon that has already been drawn to this pixel
Z-BufferAlgorithm
• Visibility testing is done during rasterization
Z-buffer: A SecondaryBuffer
DAM Entertainment
Color buffer Depth buffer
Z-Buffer
P1
P2
• How do we calculate the depth values on the polygon
interior?
P3
P4
ys za zp zb
Scanline order
p
b
a
(xa  xb)
(xa  xp )
z  za  (zb  za)
(y1  y2 )
(y1  ys )
z  z1 (z2  z1)
(y1  y4 )
(y1  ys )
z  z1 (z4  z1)
Bilinear Interpolation
Z-buffer - Example
       
       
       
       
       
       
       
       
Z-buffer
Screen

 
       
       
       
       
       
       
       
       
      
     
    
   
  
 

Parallel with
the image plane




 
  
   
    
     
       
       
       
       
       
       
       
       
Not Parallel
Z-BufferAlgorithm
 Algorithm easily handles this case
Z-buffering in OpenGL
• Create depth buffer by setting GLUT_DEPTH flag in
glutInitDisplayMode()or the appropriate flag in the
PIXELFORMATDESCRIPTOR.
• Enable per-pixel depth testing with glEnable(GL_DEPTH_TEST)
• Clear depth buffer by setting GL_DEPTH_BUFFER_BIT in glClear()

More Related Content

More from cpjcollege

Law of Crimes-I ( LLB -205)
 Law of Crimes-I  ( LLB -205)  Law of Crimes-I  ( LLB -205)
Law of Crimes-I ( LLB -205) cpjcollege
 
Socio-Legal Dimensions of Gender (LLB-507 & 509 )
Socio-Legal Dimensions of Gender (LLB-507 & 509 )Socio-Legal Dimensions of Gender (LLB-507 & 509 )
Socio-Legal Dimensions of Gender (LLB-507 & 509 )cpjcollege
 
Family Law-I ( LLB -201)
Family Law-I  ( LLB -201) Family Law-I  ( LLB -201)
Family Law-I ( LLB -201) cpjcollege
 
Alternative Dispute Resolution (ADR) [LLB -309]
Alternative Dispute Resolution (ADR) [LLB -309] Alternative Dispute Resolution (ADR) [LLB -309]
Alternative Dispute Resolution (ADR) [LLB -309] cpjcollege
 
Law of Evidence (LLB-303)
Law of Evidence  (LLB-303) Law of Evidence  (LLB-303)
Law of Evidence (LLB-303) cpjcollege
 
Environmental Studies and Environmental Laws (: LLB -301)
Environmental Studies and Environmental Laws (: LLB -301)Environmental Studies and Environmental Laws (: LLB -301)
Environmental Studies and Environmental Laws (: LLB -301)cpjcollege
 
Code of Civil Procedure (LLB -307)
 Code of Civil Procedure (LLB -307) Code of Civil Procedure (LLB -307)
Code of Civil Procedure (LLB -307)cpjcollege
 
Constitutional Law-I (LLB -203)
 Constitutional Law-I (LLB -203) Constitutional Law-I (LLB -203)
Constitutional Law-I (LLB -203)cpjcollege
 
Women and Law [LLB 409 (c)]
Women and Law [LLB 409 (c)]Women and Law [LLB 409 (c)]
Women and Law [LLB 409 (c)]cpjcollege
 
Corporate Law ( LLB- 305)
Corporate Law ( LLB- 305)Corporate Law ( LLB- 305)
Corporate Law ( LLB- 305)cpjcollege
 
Human Rights Law ( LLB -407)
 Human Rights Law ( LLB -407) Human Rights Law ( LLB -407)
Human Rights Law ( LLB -407)cpjcollege
 
Labour Law-I (LLB 401)
 Labour Law-I (LLB 401) Labour Law-I (LLB 401)
Labour Law-I (LLB 401)cpjcollege
 
Legal Ethics and Court Craft (LLB 501)
 Legal Ethics and Court Craft (LLB 501) Legal Ethics and Court Craft (LLB 501)
Legal Ethics and Court Craft (LLB 501)cpjcollege
 
Political Science-II (BALLB- 209)
Political Science-II (BALLB- 209)Political Science-II (BALLB- 209)
Political Science-II (BALLB- 209)cpjcollege
 
Health Care Law ( LLB 507 & LLB 509 )
Health Care Law ( LLB 507 & LLB 509 )Health Care Law ( LLB 507 & LLB 509 )
Health Care Law ( LLB 507 & LLB 509 )cpjcollege
 
Land and Real Estate Laws (LLB-505)
Land and Real Estate Laws (LLB-505)Land and Real Estate Laws (LLB-505)
Land and Real Estate Laws (LLB-505)cpjcollege
 
Business Environment and Ethical Practices (BBA LLB 213 )
Business Environment and Ethical Practices (BBA LLB 213 )Business Environment and Ethical Practices (BBA LLB 213 )
Business Environment and Ethical Practices (BBA LLB 213 )cpjcollege
 
HUMAN RESOURCE MANAGEMENT (BBA LLB215 )
HUMAN RESOURCE MANAGEMENT (BBA LLB215 )HUMAN RESOURCE MANAGEMENT (BBA LLB215 )
HUMAN RESOURCE MANAGEMENT (BBA LLB215 )cpjcollege
 
PRIVATE INTERNATIONAL LAW ( LLB 507 &LLB 509 )
 PRIVATE  INTERNATIONAL  LAW ( LLB 507 &LLB 509 ) PRIVATE  INTERNATIONAL  LAW ( LLB 507 &LLB 509 )
PRIVATE INTERNATIONAL LAW ( LLB 507 &LLB 509 )cpjcollege
 
CRIMINOLOGY {LLB 409 (d) }
CRIMINOLOGY {LLB 409 (d) }CRIMINOLOGY {LLB 409 (d) }
CRIMINOLOGY {LLB 409 (d) }cpjcollege
 

More from cpjcollege (20)

Law of Crimes-I ( LLB -205)
 Law of Crimes-I  ( LLB -205)  Law of Crimes-I  ( LLB -205)
Law of Crimes-I ( LLB -205)
 
Socio-Legal Dimensions of Gender (LLB-507 & 509 )
Socio-Legal Dimensions of Gender (LLB-507 & 509 )Socio-Legal Dimensions of Gender (LLB-507 & 509 )
Socio-Legal Dimensions of Gender (LLB-507 & 509 )
 
Family Law-I ( LLB -201)
Family Law-I  ( LLB -201) Family Law-I  ( LLB -201)
Family Law-I ( LLB -201)
 
Alternative Dispute Resolution (ADR) [LLB -309]
Alternative Dispute Resolution (ADR) [LLB -309] Alternative Dispute Resolution (ADR) [LLB -309]
Alternative Dispute Resolution (ADR) [LLB -309]
 
Law of Evidence (LLB-303)
Law of Evidence  (LLB-303) Law of Evidence  (LLB-303)
Law of Evidence (LLB-303)
 
Environmental Studies and Environmental Laws (: LLB -301)
Environmental Studies and Environmental Laws (: LLB -301)Environmental Studies and Environmental Laws (: LLB -301)
Environmental Studies and Environmental Laws (: LLB -301)
 
Code of Civil Procedure (LLB -307)
 Code of Civil Procedure (LLB -307) Code of Civil Procedure (LLB -307)
Code of Civil Procedure (LLB -307)
 
Constitutional Law-I (LLB -203)
 Constitutional Law-I (LLB -203) Constitutional Law-I (LLB -203)
Constitutional Law-I (LLB -203)
 
Women and Law [LLB 409 (c)]
Women and Law [LLB 409 (c)]Women and Law [LLB 409 (c)]
Women and Law [LLB 409 (c)]
 
Corporate Law ( LLB- 305)
Corporate Law ( LLB- 305)Corporate Law ( LLB- 305)
Corporate Law ( LLB- 305)
 
Human Rights Law ( LLB -407)
 Human Rights Law ( LLB -407) Human Rights Law ( LLB -407)
Human Rights Law ( LLB -407)
 
Labour Law-I (LLB 401)
 Labour Law-I (LLB 401) Labour Law-I (LLB 401)
Labour Law-I (LLB 401)
 
Legal Ethics and Court Craft (LLB 501)
 Legal Ethics and Court Craft (LLB 501) Legal Ethics and Court Craft (LLB 501)
Legal Ethics and Court Craft (LLB 501)
 
Political Science-II (BALLB- 209)
Political Science-II (BALLB- 209)Political Science-II (BALLB- 209)
Political Science-II (BALLB- 209)
 
Health Care Law ( LLB 507 & LLB 509 )
Health Care Law ( LLB 507 & LLB 509 )Health Care Law ( LLB 507 & LLB 509 )
Health Care Law ( LLB 507 & LLB 509 )
 
Land and Real Estate Laws (LLB-505)
Land and Real Estate Laws (LLB-505)Land and Real Estate Laws (LLB-505)
Land and Real Estate Laws (LLB-505)
 
Business Environment and Ethical Practices (BBA LLB 213 )
Business Environment and Ethical Practices (BBA LLB 213 )Business Environment and Ethical Practices (BBA LLB 213 )
Business Environment and Ethical Practices (BBA LLB 213 )
 
HUMAN RESOURCE MANAGEMENT (BBA LLB215 )
HUMAN RESOURCE MANAGEMENT (BBA LLB215 )HUMAN RESOURCE MANAGEMENT (BBA LLB215 )
HUMAN RESOURCE MANAGEMENT (BBA LLB215 )
 
PRIVATE INTERNATIONAL LAW ( LLB 507 &LLB 509 )
 PRIVATE  INTERNATIONAL  LAW ( LLB 507 &LLB 509 ) PRIVATE  INTERNATIONAL  LAW ( LLB 507 &LLB 509 )
PRIVATE INTERNATIONAL LAW ( LLB 507 &LLB 509 )
 
CRIMINOLOGY {LLB 409 (d) }
CRIMINOLOGY {LLB 409 (d) }CRIMINOLOGY {LLB 409 (d) }
CRIMINOLOGY {LLB 409 (d) }
 

Recently uploaded

Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 

Recently uploaded (20)

Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 

Computer Graphics BCA 303

  • 1. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India) PAPER NAME: COMPUTER GRAPHICS PAPER CODE: BCA 303 CLASS: BCA Vth Semester
  • 2. UNIT-I Graphics Display Devices • Frame Buffer – a region of memory sufficiently large to hold all of the pixel values for the display Block Diagram of Computer with Raster Display Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)2
  • 3. Graphics Display Devices - cont • How each pixel value in the frame buffer is sent to the right place on the display surface Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)3
  • 4. Graphics Devices – cont • Each pixel has a 2D address (x,y) – For each address (x,y) there is a specific memory location that holds the value of the pixel (I.e. mem[136][252]) – The scan controller sends the logical address (136, 252) to the frame buffer, which emits the value mem[136][252] – The value mem[136][252] is converted to a corresponding intensity or color in the conversion circuit, and that intensity or color is sent to the proper physical position, (136, 252), on the display surfaceChanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)4
  • 5. Graphics Devices – cont • Each pixel has a 2D address (x,y) – For each address (x,y) there is a specific memory location that holds the value of the pixel (I.e. mem[136][252]) – The scan controller sends the logical address (136, 252) to the frame buffer, which emits the value mem[136][252] – The value mem[136][252] is converted to a corresponding intensity or color in the conversion circuit, and that intensity or color is sent to the proper physical position, (136, 252), on the display surfaceChanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)5
  • 6. Graphics Devices – cont • Each pixel has a 2D address (x,y) – For each address (x,y) there is a specific memory location that holds the value of the pixel (I.e. mem[136][252]) – The scan controller sends the logical address (136, 252) to the frame buffer, which emits the value mem[136][252] – The value mem[136][252] is converted to a corresponding intensity or color in the conversion circuit, and that intensity or color is sent to the proper physical position, (136, 252), on the display surfaceChanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)6
  • 7. Graphics Devices – cont • Each pixel has a 2D address (x,y) – For each address (x,y) there is a specific memory location that holds the value of the pixel (I.e. mem[136][252]) – The scan controller sends the logical address (136, 252) to the frame buffer, which emits the value mem[136][252] – The value mem[136][252] is converted to a corresponding intensity or color in the conversion circuit, and that intensity or color is sent to the proper physical position, (136, 252), on the display surfaceChanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)7
  • 8. Graphics Devices – cont • Each pixel has a 2D address (x,y) – For each address (x,y) there is a specific memory location that holds the value of the pixel (I.e. mem[136][252]) – The scan controller sends the logical address (136, 252) to the frame buffer, which emits the value mem[136][252] – The value mem[136][252] is converted to a corresponding intensity or color in the conversion circuit, and that intensity or color is sent to the proper physical position, (136, 252), on the display surfaceChanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)8
  • 9. Scan Converting Lines • Line Drawing – Draw a line on a raster screen between 2 points – What’s wrong with the statement of the problem? • It does not say anything about which pts are allowed as end pts • It does not give aclear meaning to“draw” • It does not saywhat constitutes a“line”in the raster world • It does not say how to measure the success of the proposed algorithm Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)9
  • 10. Graphics Devices – cont • Each pixel has a 2D address (x,y) – For each address (x,y) there is a specific memory location that holds the value of the pixel (I.e. mem[136][252]) – The scan controller sends the logical address (136, 252) to the frame buffer, which emits the value mem[136][252] – The value mem[136][252] is converted to a corresponding intensity or color in the conversion circuit, and that intensity or color is sent to the proper physical position, (136, 252), on the display surfaceChanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia1)0
  • 11. Scan Converting Lines - cont • Problem Statement – Given 2 points P and Q in the plane, both with integer coordinates, determine which pixels on a raster screen should be “on” in order to make a picture of a unit-width line segment starting at point P and ending at point Q Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia1)1
  • 12. Finding the next pixel • Special Case: – Horizontal Line: • Draw pixel P and increment the x coordinate value by one to get the next pixel. – Vertical Line: • Draw the pixel P and increment the y coordinate value by one to get the next pixel – Diagonal Line: • Draw the pixel P and increment both the x and y coordinate values by one to get the next pixel – What should we use in the general case? Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia1)2
  • 13. Vertical Distance • Why can we use the vertical distance as a measure of which point is closer? – Because vertical distance is proportional to the actual distance – How do we show t – Congruent Triangl his ? es Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia1)3
  • 14. Vertical Distance – cont • By similar triangles we can see that the true distances to the line (in blue) are directly proportional to the vertical distances to the line (in black) for each point. • Therefore the point with the smaller vertical distance to the line is the closest to the line Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia1)4
  • 15. Strategy 1 – IncrementalAlgorithm • The Basic Algorithm – Find the equation of the line that connects the 2 points P and Q – Starting with the leftmost point P, increment where A = xi by 1 to calculate slope, and B = y intercept – Intensify the pixel at yi  Axi  B– This computation selects the closest pixel, the pixel whose distance to the “true” line is smallest Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia1)5
  • 16. Strategy 1 – IncrementalAlgorithm • The Incremental Algorithm – Each iteration requires a floating- point multiplication therefore, modify Yi  1  Axi  1  B  Axi  x B  yi – If , then– Thusx,a1unit chayni  g1 einyi xchAanges y by slope A, which is the slope of the line – At each step, we make incremental calculations based on the preceding step to find the next y value  Ax Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia1)6
  • 17. Strategy 1 – Incremental Algo Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia1)7
  • 18. Example Code Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia1)8
  • 19. Problem with the IncrementalAlgorithm • Rounding integers takes time • Real variables have limited precision, summing an inexact slope (A) repetitively introduces a cumulative error buildup • Variables y and A must be a real or fractional binary because the slope is a fraction – Special case needed for vertical lines Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia1)9
  • 20. Strategy 2 – Midpoint LineAlgorithm • Assumethat the line’s slope is shallow and positive ( 0< slope < 1); other slopes can be handled by suitable reflections about the principle axes • Call the lower left endpoint and the upperright endpoint x0, y0  • Assume that we hxa1 v,eyju1 st selected the pixel P at • Next, we must choose between the pixel to the right (pixel E), or one right and one up (pixel NE) • Let Q be the intersection point of the line being scan- converted with the grid line xp, yp  Chanderprabhu Jain College oxf HighxeprStu1dies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia2)0
  • 21. Strategy 2 – Midpoint Line Algorithm 1/1/2000 Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia2)1
  • 22. Strategy 2 – Midpoint LineAlgorithm • The line passes between E and NE • The point that is closer to the intersection point Q must be chosen • Observe on which side of the line the midpoint M lies: – E is closer to the line if the midpoint lies above the line (I.e. the line crosses the bottom half) – NE is closer to the line if the midpoint lies below the line, I.e., the line crosses the top half • The error, thevertical distance between the chosen pixel and the actual line is always <= ½ • The algorithm chooses NE as the next pixel for the line shown • Now, find a way to calculate on which side of the line the midpoint lies Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia2)2
  • 23. The Line • The line equation as a function f(x): – f(x) = A*x + B = dy/dx * x + B • Line equation as an implicit function: – F(x,y) = a * x + b * y + c = 0 for coefficients a, b, c where a, b != 0; from above, y *dx = dy*x + B*dx, so a = dy, b = -dx, c=B *dx, a>0 for y(0) < y(1) • Properties (proof by the case analysis): – – when any point M is on the line when any point M is above the line– F(xm, ym)  0 when any point M is below the line – OurFde(xcimsi,oynmw)illb0ebased on the value of the function at the midpoint M aFt (xm, ym) 0 2 1x 1, y  Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprpastha Universitpyand Approved by Govt of NCT of Delhi & Bar Council of India2)3
  • 24. Decision Variable • Decision Variable d: to see where • How to update d: – On the basis of picking E or NE, figure out the location of the M for that pixel, and the corresponding value of d for the next grid line – We only need the sign of F (xp 1, yp  1 2)the line lies, and then pick the nearest pixel – D  F (xp 1, yp 1 2) • If d > 0 choose pixel NE • If d < 0 choose pixel E • If d = 0 choose either one consistently Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia2)4
  • 25. Example Code Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia2)5
  • 26. Rotation About the Origin To rotate a line or polygon, we must rotate each of its vertices. To rotate point (x1,y1) to point (x2,y2) we observe: From the illustration we know that: sin (A + B) = y2/r cos (A + B) = x2/r sin A= y1/r cos A =x1/r x-axis (x1,y1) (x2,y2) A B r (0,0) y-axis UNIT-II 2-D TRANSFORMATIONS Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 27. Rotation About the Origin From the double angle formulas: sin (A + B) = sinAcosB + cosAsinB cos (A + B)= cosAcosB - sinAsinB y2/r = (y1/r)cosB +Substituting: (x1/r)sinB Therefore: y.2= yP11cosB+ x1sinB We have y1sinB P2 = R (y2) (sinB cosB) (y1) (x2) (cosB -sinB) (x1)x2 = x1cosB - = Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 28. Translations y( t )1( y ) P2 = (x1 + tx) (y1 + ty) Moving an object is called a translation. We translate a point by adding to the x and y coordinates, respectively, the amount the point should be shifted in the x and y directions. We translate an object by translating each vertex in the object. P2 = P1 + T Ty P1 = ( x1 ) T = ( tx ) Tx Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 29. Scaling Changing the size of an object is called a scale. We scale an object by scaling the x and y coordinates of each vertex in the object. P2 = .SP1 S = (sx (0 sy) 0) P1 = ( x1 ) )( y1 P2 =(sxx1) (syy1) Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 30. Homogeneous Coordinates cos ø -sin ø 0 Rø = sin ø cos ø 0 0 0 1 Sx 0 0 S = 0 Sy 0 0 0 1 1 0 T x T = 0 1 T y 0 0 1 Although the formulas we have shown are usually the most efficient way to implement programs to do scales, rotations and translations, it is easier to use matrix transformations to represent and manipulate them. In order to represent a translation as a matrix operation we use 3 x 3 matrices and pad our points to become 1 x 3 matrices. (x) Point P =(y) (1) Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 31. Composite Transformations - Scaling Given our three basic transformations we can create other transformations. Scaling with a fixed point A problem with the scale transformation is that it also moves the object being scaled. Scale a line between (2, 1) (4,1) to twice its length. (2 0 0) (0 1 0) (0 0 1) (2 0 0) (0 1 0) (0 0 1) = = Before After (2) (4) (1) (1) (1) (1) (4) (8) (1) (1) (1) (1) Chanderprabhu Jain Colle0ge 1of H2 ig3her4Stu5die6s &7 Sc8ho9olo10fLaw Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 32. Composite Transforms - Scaling (cont.) If we scale a line between (0, 1) (2,1) to twice its length, the left- hand endpoint does not move. =(2 0 0) (0 1 0) (0 0 1 ) (0 0 1) (1) (2 0 0) (1) = (0 1 0) (2) (0,0) is known as a fixed point for the basic scaling transformation. We can used composite transformations to create a scale transformation with different fixed points. 0 1 2 3 4 5 6 7 8 9 10 Before After (1) (1) (0) (0) (1) (1) (0) (1) (1) Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 33. Fixed Point Scaling Scale by 2 with fixed point = (2,1) • Translate the point (2,1) to the origin • Scale by 2 • Translate origin to point (2,1) (1 0 2) (2 0 0) (1 0 -2) = (2 0 -2) (0 1 1) (0 1 0) (0 1 -1) (0 1 0) (0 0 1) (0 0 1) (0 0 1) (0 0 1) (2 0 -2) = (0 1 0) (0 0 1) = (2) (2) (1) (1) (2 0 -2) (0 1 0) (1) (1) (0 0 1) (4) (6) (1) (1) 0 1 2 3 4 5 6 7 8 9 10 Before After Chande(r1p)rabh(u1J)ainCollege of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 34. More Fixed Point Scaling Scale by 2 with fixed point = (3,1) • Translate the point (3,1) to the origin • Scale by 2 • Translate origin to point (3,1) (1 0 3) (2 0 0) (1 0 -3) = (2 0-3) (0 1 1) (0 1 0) (0 1 -1) (0 1 0) (0 0 1) (0 0 1) (0 0 1) (0 0 1) (2 0 -3) (0 1 0) (0 0 1) = (2 0 -3) (0 1 0) (0 0 1) = 0 1 2 3 4 5 6 7 8 9 10 Before After (2) (1) (1) (1) (1) (1) Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 35. Shears Original Data y Shear x Shear 1 0 0 1 b 0 a 1 0 0 1 0 0 0 1 0 0 1 GRAPHICS --> x shear --> GRAPHICS Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 36. Reflections Reflection about the y-axis Reflection about the x-axis -1 0 0 1 0 0 0 1 0 0 -1 0 0 0 1 0 0 1 Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 37. More Reflections Reflection about the origin Reflection about the line y=x -1 0 0 0 1 0 0 -1 0 1 0 0 0 0 1 0 0 1 Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 38. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India) UNIT-III SOLID MODELING
  • 39. UNIT-III SOLID MODELING Start with these four, three-view drawings – Parts 1, 2, 3, 4 below and project all points around to show alignment of one object. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 40. Part 1 - Extrude front view (.75) inches to finish. Why front view ? Because it shows the most of the object in solid format, and all I had to do was to add depth onto the object. The width and height already exist. With width and height given in front view just add depth as shown(.75). TOP FRONT RT. SIDE EXTRUDE FRONT VIEW .75 INCHES TO FINISH. WHY FRONT VIEW? BECAUSE IT SHOWS THE MOST OF OBJECT IN SOLID FORMAT, AND ALL I HAD TO DO WAS TO ADD DEPTH ONTO THE OBJECT THAT ALREADY HAD WIDTH & HEIGHT. 0.75 0.75 TOP FRONT RT. SIDE WIDTH DEPTH TO FINISH OBJECT PLACE DEPTH ON TO THE WIDTH AND HEIGHT ALREADY GIVEN IN FRONT VIEW. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 41. Part 2 - From the top choose this part and with a polyline extrude it (1.5) inches by placing the height onto the depth. Move it, align it to midpoint, and union it to form one part. FRONT RT. SIDE 1 TOP2 From the top choose this part and with a polyline line extrude it 1.5 inches by placing the height on depth Move it, align it to midpoint and union it to form one part. You can do this many ways Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 42. Part 3 - What view would you pick to turn this drawing into parametricsolid? (front view) RT. SIDE TOP Part 3 - What view would you pick to make a parametric solid? . You only need one move. Hint - place the height onto the width. 1.00 2.50 1.00 FRO 1.00 NT 1.00 Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 43. Part 4 - What part best describes this object? (1 of right side view) The command you use is extrude. What second best part would you pick? (2 of right side view) Then also extrude. Now move number 1 to midpoint of number 2 midpoint and union. FRONT RT. SIDE PART 4 What 2 Parts would best describe the object? The command you would use is extrude. What second part would you pick? Then also extrude. Now move to midpoint and union it. 2.00 1 1.50 2 If you picked 1 and 2 you are right. 0.50 TOP 1.00 Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 44. Parts 1- 4 extruded & colored Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia) UNT in partnership with TEA. Copyright ©. All rights reserved.
  • 45. Drawing 2 See if you can turn these three-view drawings into solids. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 46. Drawing 2 Lets start with top view (shows most overall shape). Extrude up (.48) inch and place in two (.25) inch holes and subtract out the space. Place to side. Extrude back part (2.13) inches. Move to side. Extrude part 3 back (1.50) of a inch, and move to side. Rotate part 2 and part 3 parallel to part 1 position and stack them on top to finish object, as shown in part 5. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 47. Drawing 2 as Solid Model Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 48. Drawing 3 – three-view Copy all drawings and insert into CAD, then shade these to get better picture. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 49. Drawing 3 Three parts - red trace in a polyline for the overall shape and extrude down (.50) inches. Second, place in a (.25) hole and subtract out hole. Yellow draw in with a polyline for its overall shape and extrude it (.50) of a inch. Part magenta polyline in over shape and extrude back (.75). Place in red parallel top of yellow (as shown) place in magenta to the midpoint of yellow (as shown) and move to right side. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 50. Drawing 3 as Solid Model Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 51. Drawing 4 Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 52. Drawing 4 as Solid Model Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council ofIndia)
  • 53. Chanderprabhu Jain College of Higher Studies & School of Law Plot No. OCF, Sector A-8, Narela, New Delhi – 110040 (Affiliated to Guru Gobind Singh Indraprastha University and Approved by Govt of NCT of Delhi & Bar Council of India) UNIT-IV HIDDEN SURFACE REMOVAL
  • 54. UNIT-IV HIDDEN SURFACE REMOVAL(Visibility) • Assumption: All polygons are opaque • What polygons are visible with respect to your viewfrustum?  Outside: View Frustum Clipping Remove polygons outside of the view volume For example, Liang-Barsky 3D Clipping  Inside: Hidden Surface Removal Backface culling Polygons facing away from the viewer Occlusion Polygons farther away are obscured by closer polygons Full or partially occluded portions • Why should we remove these polygons? Avoid unnecessary expensive operations on these polygonslater
  • 58. Occlusion: Full, Partial, None Full Partial None • The rectangle is closer than the triangle • Should appear in front of the triangle
  • 59. Backface Culling • Avoid drawing polygons facing away from the viewer  Front-facing polygons occlude these polygons in a closedpolyhedron • Test if a polygon is front- or back-facing? front-facing back-facing Ideas?
  • 60. Detecting Back-face Polygons • The polygon normal of a … front-facing polygon points towards the viewer back-facing polygon points away from the viewer If (n  v) > 0  “back-face” If (n  v) ≤ 0  “front-face” v = view vector • Eye-space test … EASY! “back-face” if nz <0 • glCullFace(GL_BACK) back front
  • 61. Polygon Normals • Let polygon vertices v0, v1, v2,..., vn - 1 be in counterclockwise order and co-planar • Calculate normal with cross product: n = (v1 - v0) X (vn - 1 - v0) • Normalize to unit vector with n/║n║ v0 v1 v2 v4 n v3
  • 62. Normal Direction • Vertices counterclockwise  Front-facing • Vertices clockwise  Back-facing 0 1 2 0 2 1 Front facing Back facing
  • 63. Painter’s Algorithm(1) • Assumption: Later projected polygons overwrite earlier projectedpolygons Graphics Pipeline 1 12 23 3 Oops! The red polygon Should be obscured by the blue polygon
  • 64. Painter’s Algorithm(2) • Main Idea  A painter creates a pictureby drawing background scene elemens before foreground ones • Requirements  Draw polygons in back-to- front order  Need to sort the polygons by depth order to get a correct image from Shirley
  • 65. Painter’s Algorithm(3) • Sort by the depth of each polygon Graphics Pipeline 1 12 23 3 depth
  • 66. Painter’s Algorithm(4) • Compute zmin ranges for eachpolygon • Project polygons with furthest zmin first (z) depth zmin zmin zmin zmin
  • 67. Painter’s Algorithm(5) • Problem: Can you get a total sorting? zmin zmin zmin zmin Correct?
  • 68. Painter’s Algorithm(6) • Cyclic Overlap  How do we sort these three polygons? • Sorting is nontrivial  Split polygons in order to get a totalordering  Not easy to do in general
  • 69. Visibility • How do we ensure that closer polygons overwrite further ones ingeneral?
  • 70. Z-Buffer • Depth buffer (Z-Buffer) A secondary image buffer that holds depth values Same pixel resolution as the color buffer Why is it called a Z-Buffer? After eye space, depth is simply the z-coordinate • Sorting is done at the pixel level Rule: Only draw a polygon at a pixel if it is closer than a polygon that has already been drawn to this pixel
  • 71. Z-BufferAlgorithm • Visibility testing is done during rasterization
  • 72. Z-buffer: A SecondaryBuffer DAM Entertainment Color buffer Depth buffer
  • 73. Z-Buffer P1 P2 • How do we calculate the depth values on the polygon interior? P3 P4 ys za zp zb Scanline order p b a (xa  xb) (xa  xp ) z  za  (zb  za) (y1  y2 ) (y1  ys ) z  z1 (z2  z1) (y1  y4 ) (y1  ys ) z  z1 (z4  z1) Bilinear Interpolation
  • 74. Z-buffer - Example                                                                 Z-buffer Screen
  • 75.                                                                                                Parallel with the image plane
  • 76.                                                                                         Not Parallel
  • 78. Z-buffering in OpenGL • Create depth buffer by setting GLUT_DEPTH flag in glutInitDisplayMode()or the appropriate flag in the PIXELFORMATDESCRIPTOR. • Enable per-pixel depth testing with glEnable(GL_DEPTH_TEST) • Clear depth buffer by setting GL_DEPTH_BUFFER_BIT in glClear()