0% found this document useful (0 votes)
60 views17 pages

Lecture 11

The document discusses clipping in computer graphics, which involves removing parts of objects outside the visible area to optimize rendering performance. It covers various clipping techniques, including the Cohen-Sutherland algorithm for line clipping, point clipping, polygon clipping, and text clipping. Applications of clipping are highlighted in real-time rendering, CAD design, and virtual/augmented reality to enhance efficiency and visual accuracy.

Uploaded by

saadahmedd33
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views17 pages

Lecture 11

The document discusses clipping in computer graphics, which involves removing parts of objects outside the visible area to optimize rendering performance. It covers various clipping techniques, including the Cohen-Sutherland algorithm for line clipping, point clipping, polygon clipping, and text clipping. Applications of clipping are highlighted in real-time rendering, CAD design, and virtual/augmented reality to enhance efficiency and visual accuracy.

Uploaded by

saadahmedd33
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

Windowing and Clipping

Assoc. Prof. Mohamed AbdelNasser


Clipping
❑ Clipping in computer graphics refers to removing objects or parts of objects outside
of the visible area of a computer screen or viewport.

2
Window & Viewport

3
Why Do We Need Clipping?
❑ The viewing window (or viewport) often has a limited display area.
❑ Moreover, when rendering complex scenes, it’s essential to optimize performance
by discarding objects or parts of objects that viewers can’t see.
❑ Clipping helps eliminate unnecessary calculations and improves the efficiency of
rendering algorithms.
❑ Furthermore, it guarantees the display of only the visible portions of objects,
resulting in faster rendering times and a more realistic representation of a scene.

4
Clipping Rectangular Window
❑ When we want to display a scene with only those objects within a particular
rectangular window, we should first specify the window’s coordinates (Y_Max,
Y_Min, X_Max, X_Min):

5
❑ Then, we clip the objects to show only their parts in the specified window:

❑ We’ll cover clipping in two-dimensional spaces.

6
Clipping
❑ There are several clipping techniques:
❖ Cohen-Sutherland Algorithm for Line Clipping
❖ Point Clipping
❖ Polygon Clipping
❖ Curve, Exterior, and Text Clipping

❑ Different cases which are to be


consider before clipping line are:
• Completely inside.
• Completely outside.
• Partly inside.

7
Cohen-Sutherland Algorithm for Line Clipping
❑ The Cohen-Sutherland algorithm uses a region code to clip a portion of a line not
present in the visible region. It divides a region into 9 cells based on (Y_Max,
Y_Min, X_Max, X_Min):

Each cell has a code that determines its


position

8
Cohen-Sutherland Algorithm for Line Clipping
❑ The central part is the viewing window, and all lines which lie within this region are
completely visible.
❑ A region code is always assigned to the endpoints of the line based on the cells they’re in.
❑ A line segment is:
➢ Visible if both endpoints have the 0000 code
➢ Invisible if no endpoint has the 0000 code
➢ To be clipped if one endpoint has the 0000 code and the other doesn’t.

9
Cohen-Sutherland Algorithm (Example)

10
Point Clipping
❑ This type involves determining whether a point (X, Y)
is inside or outside a specific region.
❑ If any of these inequalities is false, it means that the
point lies outside the window, and therefore, it won’t
be visible:

11
Polygon Clipping
❑ We can use polygon clipping to determine which portions of the polygon are visible
to the viewer and to discard any parts of the polygon that are outside of the
viewing area:

12
Text Clipping
❑ There are additional clipping techniques that allow us to control and confine visual
elements within defined regions; for example, text clipping.
❑ We use text clipping to ensure that text is displayed only within a defined region.
❑ Text clipping is commonly used in graphic design software, web design tools, and
document processing software.

13
Exterior Clipping
❑ We can use the exterior clipping to show only the elements outside of the clipping
window.

14
Curve Clipping
❑ Curve clipping involves determining which parts of a curve lie within the viewing
window. It involves non-linear calculations.

15
Applications
Clipping in computer graphics finds applications in various contexts:

❑ Real-time rendering in video games: Clipping can optimize the performance by


rendering only the visible portions of game objects, improving frame rates and
overall gameplay experience
❑ CAD and architectural design: Clipping can also assist in displaying complex 3D
models accurately, allowing designers to focus on the visible components during
the design process
❑ Virtual reality (VR) and augmented reality (AR): Another application of clipping
in ensuring that virtual or augmented objects are rendered realistically within the
user’s field of view, enhancing the immersive experience.

16
Questions
1- Write a pseudo code for Cohen Sutherland Line Clipping Algorithm.
2- In Cohen Sutherland Line Clipping Algorithm, the viewing window
has a region code of ………
(a) 0000 (b) 0100 (c) 0000 (d) 010
3- Write a pseudo code for the Point Clipping Algorithm.

You might also like