MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.1
Unit -3T f ti Cli i
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor. U3.‹#›
Transformation, Clipping, Projections and Solid Modeling
Transformations
2-D Viewing Transformation, Computing location of Viewport, Window-to viewport transformation
Clipping
Line Clipping; Sutherland Cohen clipping algorithms, Sutherland-Hodgeman
Learning Objective
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
g
Projection
Parallel and Perspective Projections
Solid Modeling
Sweeping a polygon or a surface patch along a path to form solids, Boundary Representation (B-Rep), octrees, CSG –Constructive Solid Geometry.
Model Transformation
Viewing Transformation
Projection Transformation
3D Primitives3D Modeling Coordinates
3D World Coordinates
3D Viewing Coordinates
Viewing Pipeline
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
Clipping
Viewport Transformation
Scan Conversion
Image
2D Projection Coordinates
2D Projection Coordinates
2D Device Coordinates
2D Device Coordinates
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.2
2-D viewing is the formal mechanism for displaying views of a picture on an output device. Terms related to 2-D viewing are :
• Co-ordinate representations
• Output primitive
Att ib t
Two-Dimensional Viewing
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
• Attributes
• Transformations
Geometric
Modeling
Viewing
• Structures/ Segments/ Objects
• Co-ordinate representations
• Output primitive
• Attributes
• Transformations Geometric
Two-Dimensional Viewing
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
Modeling
Viewing
• Structures/ Segments/ Objects
• Modeling coordinates
• World coordinates
• Viewing coordinates
• Normalized viewing coordinates
• Device coordinates
Co-ordinate Representations
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
Device coordinates
(Xmc,Ymc)(Xwc,Ywc)(Xvc,Yvc)(Xnvc,Ynvc)(Xdc,Ydc)
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.3
• Co-ordinate representations
• Output primitive
• Attributes
• Transformations Modeling
Two-Dimensional Viewing
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
g
Geometric
Viewing
• Structures/ Segments/ Objects
• Co-ordinate representations
• Output primitive
• Attributes
• Transformations Modeling
Two-Dimensional Viewing
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
g
Geometric
Viewing
• Structures/ Segments/ Objects
• Co-ordinate representations
• Output primitive
• Attributes
• Transformations Modeling
Two-Dimensional Viewing
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
g
Geometric
Viewing
• Structures/ Segments/ Objects
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.4
• Co-ordinate representations
• Output primitive
• Attributes
• Transformations Modeling
Two-Dimensional Viewing
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
g
Geometric
Viewing
• Structures/ Segments/ Objects
• Window World coordinate area selected for display
It defines what is to be displayed
• Viewport An area on a display device to which a window is
d
Window-to-Viewport transformation
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
mapped
It defines where it is to be displayed
• Transform 2D Geometric Primitives from Scene Coordinate System (World Coordinates) to Image Coordinate System (Device Coordinates)
• When we are interested in displaying certain portions of the drawing, windowing technique is used
Vi i t f ti i th i f t f
Window-to-Viewport transformation
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
• Viewing transformation is the mapping of a part of a world-coordinate scene to device coordinates.
• 2D (two dimensional) viewing transformation sometimes referred to as the window-to-viewport transformation or the windowing transformation.
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.5
• Mapping a window onto a viewport involves converting from one coordinate system to another.
• Zooming effects can be achieved by successively mapping different-sized windows on a fixed-size viewport.
• Panning effects are produced by moving a fixed-size window across various sized viewport.
Viewport Transformation Cont..
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
• The mapping of a part of world co-ordinate scene to device coordinates is referred to as viewing transformation.
• A viewing transformation uses standard rectangles for the window and viewport
Window-to-Viewport transformation
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
World Coordinates
xvmin xvmax
ywmax
ywmin
Device Coordinate
xvmin xvmax
ywmax
ywmin
• Setting up a rotated world window in viewing coordinates and the corresponding normalized-coordinate viewport
1y world
Window-to-Viewport transformation
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
NormalizedDevice Coordinates
Viewpoint
0 1
World Coordinates
y0
x0 x world
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.6
Viewing Coordinate Reference Frame
• Used to provide a method for setting up arbitrary orientations for rectangular windows
• Matrix for converting world-coordinate positions to viewing coordinate
ΤRΜ
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
ΤRΜ VCWC ,
R: rotation matrixT: translation matrix
Viewing Coordinate Reference Frame
• The steps in this coordinate transformation A viewing coordinate frame is moved to
coincidence with the world frame in two stepsa) Translate the viewing origin to the world origin, thenb) Rotate to align the axes of the two systems
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
• Window-to-viewport mapping A point at position (xw, yw) in a designated
window is mapped to viewport coordinates (xv, yv) so that relative positions in the two areas are the same
Window-to-Viewport transformation cont..
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.7
xv xv -- xvxvminmin = = xwxw -- xwxwminmin
xvxvmaxmax -- xvxvminmin xwxwmaxmax -- xwxwminmin
yvyv –– yvyvminmin = = ywyw -- ywywminmin
Window-to-Viewport transformation cont..
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
yvyvmaxmax –– yvyvminmin ywywmaxmax -- ywywminmin
From these two equations we derived From these two equations we derived
xv = xv = xvxvminmin + (+ (xwxw –– xwxwminmin))sxsx
yvyv = = yvyvminmin + (+ (ywyw –– ywywminmin))sysy
where the scaling factors arewhere the scaling factors are
Window-to-Viewport transformation cont..
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
sxsx = = xvxvmaxmax –– xvxvminmin sysy = = yvyvmaxmax -- yvyvminmin
xwxwmaxmax –– xwxwminmin ywywmaxmax -- ywywminmin
Thus, the conversion of window area into viewport area is performed with the following sequence of transformations:
1. Perform a scaling that scales the window area to the size of the viewport.
Window-to-Viewport transformation cont..
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
2. Translate the scaled window area to the position of the viewport.
3. Relative proportions are maintained if the scaling factors are same (sx=sy)
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.8
Window-to-Viewport transformation cont..
• The way of character string mapping Maintaining character size
Using standard character fonts
Changing character sizeUsing characters formed with line segments
• Workstation transformation
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
Opening any number of output devices in a particular application
Performing another window-to-viewport transformation for each open output device
Window-to-Viewport transformation cont..
• Mapping selected
parts of a scene
in normalized
coordinates to
different video
monitors with
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
monitors with
Workstation
transformation
Clipping•Any procedure that identifies those portions of a picture that are either inside or outside of a specified region of space is called clipping •The region against which an object is clipped is called a clip window or viewing window•Avoid Drawing Parts of Primitives Outside Window
Window defines part of scene being viewed
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
Window defines part of scene being viewed Must draw geometric primitives only inside window
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.9
Clipping•Clipping algorithms can be considered for following primitive types PointLine Area (polygons)
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
•Assuming that the clip window is a rectangle in standard position•Saving a point P=(x, y) for display
•Appling Fields- Particles (explosion, sea foam)
yw max
Inside =xw min <= x <= xw maxyw min <= y <=yw max
Point Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
(x, y)
xw maxxw min
yw min
y max
• Find the Part of a Line Inside the Clip Window
P7
P1
Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P8
P10
P9
P2
P5
P4
P3
P6
Before Clipping
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.10
Line Clipping
• Find the Part of a Line Inside the Clip Window
P P’
P’7
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
After Clipping
P4
P3
P6
P 8
P’5
Line Clipping• Split plane into 9
regions
• Assign each a 4-bit 0000
10001001 1010
0001 0010
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
gtag(left, right, below, above)
• Assign each endpoint a tag
0000
0100
0001 0010
0101 0110clip
rectangle
Sutherland Cohen clipping algorithmsChecking for trivial acceptance or rejection usingoutcodes1. Each endpoint of a line segment is assigned an outcode;2. If both 4-bit codes are zero, the line can be accepted;3. A logical and is performed on both outcodes;4 If th lt i th li b j t d
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
4. If the result is nonzero, the line can be rejected.5. Else If not accepted or rejected, divide the line segment into
two at a clip edge6. Iteratively clipped by test acceptance or rejection, and
divided into two segments until completely inside or rejection.
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.11
Which Line is accepted or rejected or clipped
• G = 1001, H = 1000
• I = 0001, J = 1000
• A = 0000, B = 0000
• C = 0000, B = 0010
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
C 0000, B 0010
• E = 0100, F = 0100
• Use Simple Tests to Classify Easy Cases First
P7
P1
P
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P8
P10
P9
P2
P5
P4
P3
P6
Cohen-Sutherland Line Clipping
• Classify Some Lines Quickly by AND of Bit Codes Representing Regions of Two Endpoints (Must Be 0)
1000P7 1010
P1
1001Bit 4
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P10
P5
P6
P9
P80010
01100100
0000
0101
0001
P2
P4
P3
Bit 3
Bit 2Bit 1
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.12
• Classify Some Lines Quickly by AND of Bit Codes Representing Regions of Two Endpoints (Must Be 0)
1000P7 1010
P1
1001Bit 4
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P10
P5
P6
P9
P80010
01100100
0000
0101
0001
P2
P4
P3
Bit 3
Bit 2Bit 1
• Classify Some Lines Quickly by AND of Bit Codes Representing Regions of Two Endpoints (Must Be 0)
1000P7 10101001Bit 4
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P10
P5
P6
P9
P80010
01100100
0000
0101
0001P4
P3
Bit 3
Bit 2Bit 1
• Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly
1000P7 10101001Bit 4
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P10
P5
P6
P9
P80010
01100100
0000
0101
0001P4
P3
Bit 3
Bit 2Bit 1
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.13
• Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly
1000P7 10101001Bit 4
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P10
P5
P6
P9
P80010
01100100
0000
0101
0001P4
P3
Bit 3
Bit 2Bit 1
• Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly
1000P7 10101001Bit 4
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P10
P6
P9
P80010
01100100
0000
0101
0001P4
P3
Bit 3
Bit 2Bit 1
P’5
• Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly
1000P7 10101001Bit 4
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P10
P6
P9
P80010
01100100
0000
0101
0001P4
P3
Bit 3
Bit 2Bit 1
P’5
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.14
• Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly
1000P7 10101001Bit 4
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P10
P6
P9
P80010
01100100
0000
0101
0001P4
P3
Bit 3
Bit 2Bit 1
P’5
• Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly
1000P7 10101001Bit 4
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P10
P6
P9
P80010
01100100
0000
0101
0001P4
P3
Bit 3
Bit 2Bit 1
P’5
• Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly
1000 10101001Bit 4
P’7
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P10
P6
P9
P80010
01100100
0000
0101
0001P4
P3
Bit 3
Bit 2Bit 1
P’5
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.15
• Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly
1000 10101001Bit 4
P’7
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P10
P6
P9
P80010
01100100
0000
0101
0001P4
P3
Bit 3
Bit 2Bit 1
P’5
• Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly
1000 10101001Bit 4
P’7
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P10
P6
P9
0010
01100100
0000
0101
0001P4
P3
Bit 3
Bit 2Bit 1
P’5
P’8
• Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly
1000 10101001Bit 4
P’7
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P10
P6
P9
0010
01100100
0000
0101
0001P4
P3
Bit 3
Bit 2Bit 1
P’5
P’8
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.16
• Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly
1000 10101001Bit 4
P’7
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P10
P6
P9
0010
01100100
0000
0101
0001P4
P3
Bit 3
Bit 2Bit 1
P’5
P’8
• Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly
1000 10101001Bit 4
P’7
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P10
P6
P9
0010
01100100
0000
0101
0001P4
P3
Bit 3
Bit 2Bit 1
P’5
P’8
• Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly
1000 10101001Bit 4
P’7
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P10
P6
0010
01100100
0000
0101
0001P4
P3
Bit 3
Bit 2Bit 1
P’5
P’8
P’9
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.17
• Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly
1000 10101001Bit 4
P’7
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P10
P6
P’9
0010
01100100
0000
0101
0001P4
P3
Bit 3
Bit 2Bit 1
P’5
P’8
• Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly
1000 10101001Bit 4
P’7
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P10
P6
0010
01100100
0000
0101
0001P4
P3
Bit 3
Bit 2Bit 1
P’5
P’8
P’’9
• Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly
1000 10101001Bit 4
P’7
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P6
0010
01100100
0000
0101
0001P4
P3
Bit 3
Bit 2Bit 1
P’5
P’8
P10
P’’9
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.18
• Compute Intersections with Window Boundary for Lines That Can’t be Classified Quickly
1000 10101001Bit 4
P’7
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
P6
0010
01100100
0000
0101
0001P4
P3
Bit 3
Bit 2Bit 1
P’5
P’8
Intersection points with a clipping boundary :
x= x1 + (y-y1)
m
y= y1 + m(x-x1)
Cohen-Sutherland Line Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
y y1 m(x x1)
Where x = either xwmin or xwmax
y = either ywmin or ywmax
m = (y2 – y1) / (x2 – x1 )
Sutherland-Hodgman Clipping Algorithm
• To clip an area against an individual boundary: Consider each vertex in turn against the boundary
Vertices inside the boundary are saved for clipping against the next boundary
V ti t id th b d li d
Polygon Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
Vertices outside the boundary are clipped
If we proceed from a point inside the boundary to one outside, the intersection of the line with the boundary is saved
If we cross from the outside to the inside intersection point and the vertex are saved
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.19
• Each example shows the point being processed (P) and the previous point (S)
• Saved points define area clipped to the
S
P S
P
I
Polygon Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
ppboundary in question
Save Point P Save Point I
P
SNo Points Saved
SP
Save Points J & P
J
• Find the Part of a Polygon Inside the Clip Window?
Polygon Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
Before Clipping
• Find the Part of a Polygon Inside the Clip Window?
Polygon Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
After Clipping
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.20
• Clip to Each Window Boundary One at a Time
Sutherland-Hodgeman Polygon Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
• Clip to Each Window Boundary One at a Time
Sutherland-Hodgeman Polygon Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
• Clip to Each Window Boundary One at a Time
Sutherland-Hodgeman Polygon Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.21
• Clip to Each Window Boundary One at a Time
Sutherland-Hodgeman Polygon Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
• Clip to Each Window Boundary One at a Time
Sutherland-Hodgeman Polygon Clipping
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
Projections
• General definition Transform points in n-space to m-space(m<n)
• In computer graphics Map viewing coordinates to 2D screen coordinates
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.22
Taxonomy of Projections
Planar geometric projection
Parallel Perspective
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
Orthographic Oblique
Top
FrontSide
Axonometric Cabinet
Cavalier
Other
One-pointTwo-point
Three-point
Projections
• Parallel Projection
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
• Perspective Projection
• Center of projection is at infinity Direction of projection (DOP) same for all points
Parallel Projection
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
View Plane
DOP
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.23
• Orthographic parallel projection the projection is perpendicular to the view plane
Orthographic and Oblique
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
• Oblique parallel projection The projectors are inclined with respect to the view
plane
Orthographic Projections
• DOP perpendicular to view plane
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
Front
Top Side
Oblique Projections
• DOP not perpendicular to view plane
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
Cavalier(DOP at 45 )
Cabinet(DOP at 63.4 )
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.24
• Map points onto “view plane” along “projectors” emanating from “center of projection”(cop)
Perspective Projection
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
View PlaneCenter of Projection
• Used for:• Human visual system…
• Pros:• gives a realistic view and feeling for 3D form of object
• Cons:
Perspective Projection
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
• does not preserve shape of object or scale
• Different from a parallel projection because• parallel lines not parallel to the projection plane converge
• size of object is diminished with distance
• foreshortening is not uniform
What is vanishing point?
• A vanishing point is where parallel lines that move off into the distance seem to converge.
• In computer graphics, lines extending from edges converge to common vanishing point(s)
Perspective Projection
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
y
x
y
x
z
z
Three Point Perspective(z, x, and y-axis vanishing points)
Two Point Perspective(z, and x-axis vanishing points)
One Point Perspective(z-axis vanishing point)
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.25
• How many vanishing point?
Perspective Projection
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
• How many vanishing point?
Perspective Projection
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
Three-point perspective
• How many vanishing point?
Perspective Projection
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›cgvr.korea.ac.
Three-point perspective
Two-point perspective
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.26
• How many vanishing point?
Perspective Projection
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›cgvr.korea.ac.
Three-point perspective
Two-point perspective
One-point perspective
Perspective vs. Parallel
• Perspective projection+ Size varies inversely with distance – looks realistic
– Distance and angles are not(in general) preserved
– Parallel line do not (in general) remain parallel
P ll l j ti
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
• Parallel projection + Good for exact measurements
+ Parallel lines remain parallel
– Angles are not (in general) preserved
– Less realistic looking
• It is a mathematical technique for representing solid objects in terms of basic output primitives and splines.
• Representation of solids can be done in following ways :
Solid Modeling
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
Sweep representations
Boundary representations (B-Reps)
Space-partitioning representations (Octrees, BSP trees)
Constructive Solid Geometry (CSG)
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.27
Sweep Representations
• Sweep representations are useful for constructing 3-D objects that posses translational or rotational symmetries.
• A large class of shapes can be formed by sweeping a 2D shape through space.
Solid Modeling
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
• Sweeps can be :
Translational
Rotational
Boundary Representation (B-Rep)• A solid is modeled as a set of surfaces forming its boundary.• These surfaces seperate object interior from environment.• Example : Polygon facets
Topology and Geometry1 T l h th f t d t th
Solid Modeling Cont..
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
1. Topology – how the surfaces are connected together.
2. Geometry – where the surfaces actually are in space.
3. Topology and Geometry are strongly linked.
• The most commonly used boundary representation for a 3-D graphics object is a set of surface polygons that enclose the object interior.
• All surfaces are described with linear equations.
• There are different ways for describing a Polygon
Solid Modeling Cont..
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
Surface :
- Polygon tables (vertex, edge and polygon-surface table)
- Plane Equation
- Polygon meshes (triangle strip, quadrilateral mesh)
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.28
Solid Modeling Cont..
• Recursive Partition of Space by Planes Mark leaf cells as inside or outside object
11
a
b
Binary Space Partitions (BSPs)
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
a
bcd
e
f
g
Object
a
bcd
e
f
g
Binary Spatial Partition
2
3
4
5
6
7
2
3
c
4
d
5
6
e
7
f
BSP Tree
Quadtree and Octrees:
A quadtree is a tree in which each node has at most 4 children.
An octree is a tree in which each node has at most 8 children
Solid Modeling Cont..
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
children.
In practice, however, we use “quadtree” and “octree” to mean something more specific:
Each node of the tree corresponds to a square (quadtree) or cubical (octree) region.
If a node has children, think of its region being chopped into 4 (quadtree) or 8 (octree) equal subregions. Child
Solid Modeling Cont..
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
nodes correspond to these smaller subregions of their parent’s region.
Subdivide as little or as much as is necessary.
Each internal node has exactly 4 (quadtree) or 8 (octree) children.
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.29
Quadtree Representation
0 1
3 2
Solid Modeling Cont..
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
Octrees Representations
Solid Modeling Cont..
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
Region of a 3D space
Data element in the Representative
Octree Node
• Constructive Solid Geometry (CSG)
• Represent solid object as hierarchy of boolean operations Union
Difference
Solid Modeling Cont..
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
Intersection
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.30
Solid Modeling Cont..
• Union The sum of all points in each of two defined sets. (logical
“OR”)
Also referred to as Add, Combine, Join, Merge
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
A BA B
• Difference– logical “NOT” Representation
– Also referred to as subtraction, remove, cut
Solid Modeling Cont..
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
A - BA B
• intersection– Those points common to each of two defined
sets (logical “AND”)
– Set must share common volume
– Also referred to as common, conjoin
Solid Modeling Cont..
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
Also referred to as common, conjoin
A B
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.31
In this unit we understand the various features like Vanishing point projection, Viewing and window to viewport transformation and various concepts of li i d S lid d li ll
Conclusion
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
clipping and Solid modeling as well.
Short answer type Questions
1. Define Vanishing Point.
2. What do you mean by aspect ratio? Give its significance.
3. Define a viewport.
Review Questions cont..
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
p
4. Explain with the help of an example Window-to-viewport transformation.
5. What do you mean by Quad tree? Explain with an example.
6. Define Clipping with reference to Computer Graphics.
Long answer type Questions
1. What do you mean by Solid modeling? Explain various aspects of Solid modeling with example.
2. Explain Sutherland-Hodgman Clipping Algorithm? With the help of an example.
Review Questions cont..
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
3. Explain Sutherland Cohen clipping algorithms? With the help of an example.
4. Differentiate between parallel and perspective projection.
5. Differentiate between Quad tree and Octree methods?
MCA 203, Computer Graphics
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3.32
[1]. Donnald Hearn and M. Pauline Baker, “Computer Graphics”, PHI.
[2]. Foley James D, “Computer Graphics”, AW 2nd Ed.
[3] Rogers “Procedural Element of Computer
Suggested Reading/References
© Bharati Vidyapeeth’s Institute of Computer Applications and Management, New Delhi-63, by Vaishali Joshi, Assistant Professor U3. ‹#›
[3]. Rogers, Procedural Element of Computer Graphics”, McGraw Hill.
[4]. Newman and Sproul, “Principal of to Interactive Computer Graphics”, McGraw Hill.
[5]. Graphics lab @ Korea University.