Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 32

Jan 2019

3a. how do you classify the polygon? Explain openGL polygon fill primitives.
Polygon Classifications

✓ Polygons are classified into two types

1. Convex Polygon and

2. Concave Polygon

Convex Polygon:

✓ The polygon is convex if all interior angles of a polygon are less than or equal to 180◦, where an
interior angle of a polygon is an angle inside the polygon boundary that is formed by two adjacent
edges

✓ An equivalent definition of a convex polygon is that its interior lies completely on one side of the
infinite extension line of any one of its edges.

✓ Also, if we select any two points in the interior of a convex polygon, the line segment joining the
two points is also in the interior.

Concave Polygon:

✓ A polygon that is not convex is called a concave polygon. The below figure shows convex and
concave polygon

✓ The term degenerate polygon is often used to describe a set of vertices that are collinear or that
have repeated coordinate positions.

Problems in concave polygon: ➔ Implementations of fill algorithms and other graphics routines are
more complicated

Solution: ➔ It is generally more efficient to split a concave polygon into a set of convex polygons
before processing.

When rendering a polygon, OpenGL provides several primitive types that can be used to fill the
interior of the shape. These primitives include:

Sure, here are some examples of how each of the OpenGL polygon fill primitives can be used:
1. GL_POINTS: Suppose we have a set of 2D points that we want to plot as a scatter plot. We could
use GL_POINTS to render each point as a single pixel on the screen. Here's some example code:

```

glBegin(GL_POINTS);

for (int i = 0; i < numPoints; i++) {

glVertex2f(points[i].x, points[i].y);

glEnd();

```

2. GL_LINES: Suppose we want to draw a simple rectangle on the screen. We could use GL_LINES to
connect the four corners of the rectangle with straight lines. Here's some example code:

```

glBegin(GL_LINES);

glVertex2f(0, 0);

glVertex2f(0, 1);

glVertex2f(0, 1);

glVertex2f(1, 1);

glVertex2f(1, 1);

glVertex2f(1, 0);

glVertex2f(1, 0);

glVertex2f(0, 0);

glEnd();

```

3. GL_LINE_STRIP: Suppose we want to draw a simple curve on the screen that starts at (0,0) and
ends at (1,1). We could use GL_LINE_STRIP to connect a series of points that define the curve. Here's
some example code:

```
glBegin(GL_LINE_STRIP);

glVertex2f(0, 0);

glVertex2f(0.2, 0.4);

glVertex2f(0.4, 0.6);

glVertex2f(0.6, 0.8);

glVertex2f(0.8, 1);

glVertex2f(1, 1);

glEnd();

```

4. GL_LINE_LOOP: Suppose we want to draw a simple closed shape on the screen, such as a square.
We could use GL_LINE_LOOP to connect the four corners of the square with straight lines. Here's
some example code:

```

glBegin(GL_LINE_LOOP);

glVertex2f(0, 0);

glVertex2f(0, 1);

glVertex2f(1, 1);

glVertex2f(1, 0);

glEnd();

```

5. GL_TRIANGLES: Suppose we want to draw a simple triangle on the screen. We could use
GL_TRIANGLES to define the three vertices of the triangle. Here's some example code:

```

glBegin(GL_TRIANGLES);

glVertex2f(0, 0);

glVertex2f(0.5, 1);

glVertex2f(1, 0);

glEnd();
```

6. GL_TRIANGLE_STRIP: Suppose we want to draw a more complex shape on the screen, such as a
curved surface. We could use GL_TRIANGLE_STRIP to define a series of connected triangles that
approximate the surface. Here's some example code:

```

glBegin(GL_TRIANGLE_STRIP);

glVertex3f(0, 0, 0);

glVertex3f(0, 1, 0);

glVertex3f(1, 0, 0);

glVertex3f(1, 1, 0);

glVertex3f(1, 0.5, 0.5);

glEnd();

```

7. GL_TRIANGLE_FAN: Suppose we want to draw a circular shape on the screen. We could use
GL_TRIANGLE_FAN to define a series of connected triangles that approximate the circle. Here's some
example code:

```

glBegin(GL_TRIANGLE_FAN);

glVertex2f(0, 0);

for (int i = 0; i <= numSegments; i++) {

float angle = i * 2 * PI / numSegments;

glVertex2f(radius * cos(angle), radius * sin(angle));

glEnd();

```

In each of these examples, the glBegin and glEnd functions are used to define a block of code that
specifies the vertices and primitive type for the polygon. The glVertex functions are used to specify
the individual vertices of the polygon.
b. Explain translation, Scaling, rotation in 2D homogenous coordinate system
with matrix representations.
(refer formula sheet)
In computer graphics, it's common to work with objects represented in a homogeneous coordinate
system, which is a 4D coordinate system that extends the traditional 3D coordinate system with an
additional dimension that allows for transformations like translation, scaling, and rotation. These
transformations can be represented using matrix operations.

1. Translation: Translation is a transformation that moves an object from one location to another in
2D space. Given a vector (tx, ty) representing the translation amount in the x and y directions, we
can represent a translation operation as a matrix:

```

| 1 0 tx |

| 0 1 ty |

|001 |

```

This matrix can be used to transform a homogeneous coordinate (x, y, 1) to a new location (x', y', 1)
by multiplying the original coordinate by the translation matrix:

```

| x' | | 1 0 tx | | x |

| y' | = | 0 1 ty | * | y |

|1 | |001 | |1|

```

2. Scaling: Scaling is a transformation that changes the size of an object in 2D space. Given scaling
factors sx and sy for the x and y directions, we can represent a scaling operation as a matrix:

```

| sx 0 0 |

| 0 sy 0 |

|0 0 1|

```

This matrix can be used to transform a homogeneous coordinate (x, y, 1) to a new location (x', y', 1)
by multiplying the original coordinate by the scaling matrix:

```

| x' | | sx 0 0 | | x |

| y' | = | 0 sy 0 | * | y |
|1 | |0 0 1| |1|

```

3. Rotation: Rotation is a transformation that rotates an object around a fixed point in 2D space.
Given an angle theta for the amount of rotation in radians, we can represent a rotation operation as
a matrix:

```

| cos(theta) -sin(theta) 0 |

| sin(theta) cos(theta) 0 |

|0 0 1|

```

This matrix can be used to transform a homogeneous coordinate (x, y, 1) to a new location (x', y', 1)
by multiplying the original coordinate by the rotation matrix:

```

| x' | | cos(theta) -sin(theta) 0 | | x |

| y' | = | sin(theta) cos(theta) 0 | * | y |

|1 | |0 0 1| |1|

```

Using these matrix representations, we can combine multiple transformations (such as translation
followed by scaling followed by rotation) by multiplying the corresponding matrices together. For
example, to perform a translation followed by a scaling followed by a rotation, we can multiply the
translation matrix, scaling matrix, and rotation matrix together in the appropriate order:

```

T*S*R

```

where T is the translation matrix, S is the scaling matrix, and R is the rotation matrix. The resulting
matrix can then be used to transform the original homogeneous coordinate to the final position.

4a. explain general scan-line polygon-fill algorithm in detail.


b. what’re the entities required to perform a rotation? Show that two
successive rotations are additive.
For rotation, we have to specify the angle of rotation and rotation point. Rotation point a.k.a pivot
point.

Aug-2022
3a. what is the need of Homogenous coordinate system?
Homogeneous coordinates are used in computer graphics because they
provide a way to represent affine transformations (such as translation,
rotation, scaling, and shearing) using matrix multiplication.
In a homogeneous coordinate system, a point in 2D or 3D space is represented
as a vector with an additional coordinate, typically set to 1. Homogeneous
coordinates allow affine transformations to be represented as a matrix
multiplication, which can be more efficiently computed than applying the
transformations individually to each point.
Additionally, homogeneous coordinates allow for the representation of points
at infinity, which cannot be represented in a traditional Cartesian coordinate
system. This is useful in computer graphics, where points at infinity are often
used to represent vanishing points, light sources, and other important
features.
In summary, homogeneous coordinates are essential in computer graphics
because they allow for efficient representation and manipulation
of geometric transformations, as well as the representation of points at
infinity.
(xh/h,yh/h,h) usually h=1
Explain translation, rotation and scaling in 2D Homogenous coordinate
system, with matrix representation. (Repeat)
b. Explain with example any two algorithm used to identify interior and
exterior area of a polygon.
Identifying interior and exterior region of polygon.

➢ We may want to specify a complex fill region with intersecting edges.

➢ For such shapes, it is not always clear which regions of the xy plane we
should call “interior” and which regions.
➢ We should designate as “exterior” to the object boundaries.

➢ Two commonly used algorithms


1. Odd-Even rule and
2. The nonzero winding-number rule.
Inside-Outside Tests

Watch this better: https://youtu.be/X2Mn4ozMtbQ and this


https://youtu.be/ut23DURRZ6w
✓ Also called the odd-parity rule or the even-odd rule.

✓ Draw a line from any position P to a distant point outside the coordinate extents of the closed
polyline.
✓ Then we count the number of line-segment crossings along this line.

✓ If the number of segments crossed by this line is odd, then P is considered to be an interior point
Otherwise, P is an exterior point

✓ We can use this procedure, for example, to fill the interior region between two concentric circles
or two concentric polygons with a specified colour.

Nonzero Winding-Number rule

✓ This counts the number of times that the boundary of an object “winds” around a particular point
in the counter-clockwise direction termed as winding number,

✓ Initialize the winding number to 0 and again imagining a line drawn from any position P to a
distant point beyond the coordinate extents of the object.

✓ The line we choose must not pass through any endpoint coordinates.

✓ As we move along the line from position P to the distant point, we count the number of object line
segments that cross the reference line in each direction

✓ We add 1 to the winding number every time we intersect a segment that crosses the line in the
direction from right to left, and we subtract 1 very time we intersect a segment that crosses from left
to right

✓ If the winding number is nonzero, P is considered to be an interior point. Otherwise, P is taken to


be an exterior point

✓ The nonzero winding-number rule tends to classify as interior some areas that the oddeven rule
deems to be exterior.

✓ Variations of the nonzero winding-number rule can be used to define interior regions in other
ways define a point to be interior if its winding number is positive or if it is negative; or we could use
any other rule to generate a variety of fill shapes

✓ Boolean operations are used to specify a fill area as a combination of two regions
✓ One way to implement Boolean operations is by using a variation of the basic winding-number
rule consider the direction for each boundary to be counter-clockwise, the union of two regions
would consist of those points whose winding number is positive

✓ The intersection of two regions with counterclockwise boundaries would contain those points
whose winding number is greater than 1,

▪ To set up a fill area that is the difference of two regions (say, A − B), we can enclose region A with a
counter-clockwise border and B with a clockwise border

EXAMPLES:

The odd-even rule and the nonzero winding-number rule are two commonly used algorithms for
determining whether a point is inside or outside a polygon. Here is an example of how each
algorithm works:

1. Odd-Even rule:

The odd-even rule, also known as the "even-odd" rule, works by counting the number of times a ray
from the point intersects the polygon edges. If the number of intersections is odd, the point is inside
the polygon, otherwise, it is outside.

Consider the following polygon:

```

(1,2)------(5,6)

| |
| |

(2,5)------(4,3)

```

To determine whether the point P(3,4) is inside or outside the polygon using the odd-even rule, we
draw a horizontal ray from P as shown below:

```

(1,2)------(5,6)

| |

| P |

(2,5)------(4,3)

```

The ray intersects the polygon edges twice, at points (2,5) and (4,3), so the total number of
intersections is 2, which is even. Therefore, the point P is outside the polygon.

2. Nonzero winding-number rule:

The nonzero winding-number rule works by counting the number of times the polygon winds around
the point in a counterclockwise direction. If the winding number is zero, the point is outside the
polygon, otherwise, it is inside.

Consider the same polygon as before:

```

(1,2)------(5,6)

| |

| |

(2,5)------(4,3)

```
To determine whether the point P(3,4) is inside or outside the polygon using the nonzero winding-
number rule, we draw a small circle around the point and count the number of times the polygon
edges cross the circle in a counterclockwise direction:

```

(1,2)------(5,6)

| |

| o |

(2,5)------(4,3)

```

In this case, the polygon winds around the point once in a counterclockwise direction, so the winding
number is 1. Therefore, the point P is inside the polygon.

Both the odd-even rule and the nonzero winding-number rule are commonly used in computer
graphics and other fields where polygonal objects are analyzed. The choice of algorithm depends on
the specific application and the properties of the polygon being analyzed.

c. Explain 2D viewing transformation pipe line.


The Two-Dimensional Viewing Pipeline

➢ A section of a two-dimensional scene that is selected for display is called a clipping Window.

➢ Sometimes the clipping window is alluded to as the world window or the viewing window

➢ Graphics packages allow us also to control the placement within the display window using
another “window” called the viewport.

➢ The clipping window selects what we want to see; the viewport indicates where it is to be viewed
on the output device.

➢ By changing the position of a viewport, we can view objects at different positions on the display
area of an output device

➢ Usually, clipping windows and viewports are rectangles in standard position, with the rectangle
edges parallel to the coordinate axes.

➢ We first consider only rectangular viewports and clipping windows, as illustrated in Figure
Viewing Pipeline

➢ The mapping of a two-dimensional, world-coordinate scene description to device coordinates is


called a two-dimensional viewing transformation.

➢ This transformation is simply referred to as the window-to-viewport transformation or the


windowing transformation

➢ We can describe the steps for two-dimensional viewing as indicated in Figure

➢ Once a world-coordinate scene has been constructed, we could set up a separate


twodimensional, viewing coordinate reference frame for specifying the clipping window.

➢ To make the viewing process independent of the requirements of any output device, graphics
systems convert object descriptions to normalized coordinates and apply the clipping routines.

➢ Systems use normalized coordinates in the range from 0 to 1, and others use a normalized range
from −1 to 1.

➢ At the final step of the viewing transformation, the contents of the viewport are transferred to
positions within the display window.

➢ Clipping is usually performed in normalized coordinates.

➢ This allows us to reduce computations by first concatenating the various transformation matrices

4a. Explain scan line polygon fill algorithm. (Repeat)


b. Explain different OpenGL routines used for manipulating display window.
OpenGL provides several routines for manipulating the display window,
including:
1. glViewport(): This routine sets the dimensions of the viewport in the
window, which is the area of the window where OpenGL displays the
results of its rendering operations. The viewport is specified in pixels and
is typically set to the same size as the window.
2. glClear(): This routine clears the color, depth, and stencil buffers of the
window, which is necessary before rendering a new frame. The color
buffer stores the colors of the pixels in the viewport, while the depth
buffer stores the depth values of the pixels, and the stencil buffer stores
stencil values that can be used for masking or other effects.
3. glClearColor(): This routine sets the background color of the window,
which is used when clearing the color buffer. The color is specified as a
set of red, green, blue, and alpha values, each in the range 0 to 1.
4. glMatrixMode(): This routine sets the current matrix mode, which
determines whether subsequent transformations affect the modelview
matrix (for transforming objects in the scene) or the projection
matrix (for setting up the viewing frustum).
5. glLoadIdentity(): This routine sets the current matrix to the identity
matrix, which is the starting point for most transformations.
6. glOrtho(): This routine sets up an orthographic projection matrix, which
is used for rendering 2D graphics. It specifies the left, right, bottom,
and top boundaries of the viewing frustum.
7. gluPerspective(): This routine sets up a perspective projection matrix,
which is used for rendering 3D graphics. It specifies the field of
view, aspect ratio, and near and far clipping planes of the viewing
frustum.
8. glTranslatef(), glRotatef(), glScalef(): These routines apply translations,
rotations, and scaling transformations to the current matrix, which can
be used to position and orient objects in the scene.
9. glPushMatrix(), glPopMatrix(): These routines save and restore the
current matrix on a stack, which is useful for preserving transformations
when rendering nested objects.
c. Explain OpenGL 2D- viewing function.
(write whatever you remember)
OpenGL Two-Dimensional Viewing Functions

• The GLU library provides a function for specifying a two-dimensional clipping window, and we have
GLUT library functions for handling display windows.

OpenGL Projection Mode

✓ Before we select a clipping window and a viewport in OpenGL, we need to establish the
appropriate mode for constructing the matrix to transform from world coordinates to screen
coordinates

✓ We must set the parameters for the clipping window as part of the projection transformation.

✓ Function:

glMatrixMode (GL_PROJECTION);

✓ We can also set the initialization as

glLoadIdentity ( );

This ensures that each time we enter the projection mode, the matrix will be reset to the identity
matrix so that the new viewing parameters are not combined with the previous ones

GLU Clipping-Window Function

✓ To define a two-dimensional clipping window, we can use the GLU function:

gluOrtho2D (xwmin, xwmax, ywmin, ywmax);

✓ This function specifies an orthogonal projection for mapping the scene to the screen the
orthogonal projection has no effect on our two-dimensional scene other than to convert object
positions to normalized coordinates.

✓ Normalized coordinates in the range from −1 to 1 are used in the OpenGL clipping routines.

✓ Objects outside the normalized square (and outside the clipping window) are eliminated from the
scene to be displayed.

✓ If we do not specify a clipping window in an application program, the default coordinates are
(xwmin, ywmin) = (−1.0, −1.0) and (xwmax, ywmax) = (1.0, 1.0).

✓ Thus the default clipping window is the normalized square centered on the coordinate origin with
a side length of 2.0.

OpenGL Viewport Function

✓ We specify the viewport parameters with the OpenGL function

glViewport (xvmin, yvmin, vpWidth, vpHeight);


Where, ➔ xvmin and yvmin specify the position of the lowerleft corner of the viewport relative to
the lower-left corner of the display window,

➔ vpWidth and vpHeight are pixel width and height of the viewport

✓ Coordinates for the upper-right corner of the viewport are calculated for this transformation
matrix in terms of the viewport width and height:

Xvmax=xvmin+vpWidth, yvmax=yvmin+vpHeight

✓ Multiple viewports can be created in OpenGL for a variety of applications.

✓ We can obtain the parameters for the currently active viewport using the query function
glGetIntegerv (GL_VIEWPORT, vpArray);

where,

➔ vpArray is a single-subscript, four-element array.

Creating a GLUT Display Window

✓ The GLUT library interfaces with any window-management system, we use the GLUT routines for
creating and manipulating display windows so that our example programs will be independent of
any specific machine.

✓ We first need to initialize GLUT with the following function:

glutInit (&argc, argv);

✓ We have three functions inGLUT for defining a display window and choosing its dimensions and
position:

1. glutInitWindowPosition (xTopLeft, yTopLeft);

➔ gives the integer, screen-coordinate position for the top-left corner of the display window,
relative to the top-left corner of the screen

2. glutInitWindowSize (dwWidth, dwHeight);

➔ we choose a width and height for the display window in positive integer pixel dimensions.

➔ If we do not use these two functions to specify a size and position, the default size is 300 by 300
and the default position is (−1, −1), which leaves the positioning of the display window to the
window-management system

3. glutCreateWindow ("Title of Display Window");

➔ creates the display window, with the specified size and position, and assigns a title, although the
use of the title also depends on the windowing system

Setting the GLUT Display-Window Mode and Colour

✓ Various display-window parameters are selected with the GLUT function

1. glutInitDisplayMode (mode);
➔ We use this function to choose a color mode (RGB or index) and different buffer combinations,
and the selected parameters are combined with the logical or operation.

2. glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);

➔ The color mode specification GLUT_RGB is equivalent to GLUT_RGBA.

3. glClearColor (red, green, blue, alpha);

➔ A background color for the display window is chosen in RGB mode with the OpenGL routine

4. glClearIndex (index);

➔ This function sets the display window color using color-index mode,

➔ Where parameter index is assigned an integer value corresponding to a position within the color
table. GLUT Display-Window Identifier

✓ Multiple display windows can be created for an application, and each is assigned a positive-
integer display-window identifier, starting with the value 1 for the first window that is created.

✓ Function: windowID = glutCreateWindow ("A Display Window");

Deleting a GLUT Display Window

✓ If we know the display window’s identifier, we can eliminate it with the statement

glutDestroyWindow (windowID);

Current GLUT Display Window

✓ When we specify any display-window operation, it is applied to the current display

window, which is either the last display window that we created or the one.

✓ we select with the following command

glutSetWindow (windowID);

✓ We can query the system to determine which window is the current display window:

currentWindowID = glutGetWindow ( );

➔ A value of 0 is returned by this function if there are no display windows or if the

current display window was destroyed

Relocating and Resizing a GLUT Display Window

✓ We can reset the screen location for the current display window with the function

glutPositionWindow (xNewTopLeft, yNewTopLeft);

✓ Similarly, the following function resets the size of the current display window:

glutReshapeWindow (dwNewWidth, dwNewHeight);

✓ With the following command, we can expand the current display window to fill the
screen:

glutFullScreen ( );

✓ Whenever the size of a display window is changed, its aspect ratio may change and

objects may be distorted from their original shapes. We can adjust for a change in

display-window dimensions using the statement

glutReshapeFunc (winReshapeFcn);

Managing Multiple GLUT Display Windows

✓ The GLUT library also has a number of routines for manipulating a display window in

various ways.

✓ We use the following routine to convert the current display window to an icon in the form

of a small picture or symbol representing the window:

glutIconifyWindow ( );

✓ The label on this icon will be the same name that we assigned to the window, but we can

change this with the following command:

glutSetIconTitle ("Icon Name");

✓ We also can change the name of the display window with a similar command:

glutSetWindowTitle ("New Window Name");

✓ We can choose any display window to be in front of all other windows by first

designating it as the current window, and then issuing the “pop-window” command:

glutSetWindow (windowID);

glutPopWindow ( );

✓ In a similar way, we can “push” the current display window to the back so that it is

behind all other display windows. This sequence of operations is

glutSetWindow (windowID);

glutPushWindow ( );

✓ We can also take the current window off the screen with

glutHideWindow ( );

✓ In addition, we can return a “hidden” display window, or one that has been converted to

an icon, by designating it as the current display window and then invoking the function

glutShowWindow ( );
GLUT Subwindows

✓ Within a selected display window, we can set up any number of second-level display

windows, which are called subwindows.

✓ We create a subwindow with the following function:

glutCreateSubWindow (windowID, xBottomLeft, yBottomLeft, width, height);

✓ Parameter windowID identifies the display window in which we want to set up the

Subwindow

✓ Subwindows are assigned a positive integer identifier in the same way that first-level

display windows are numbered, and we can place a subwindow inside another

subwindow.

✓ Each subwindow can be assigned an individual display mode and other parameters. We

can even reshape, reposition, push, pop, hide, and show subwindows

Selecting a Display-Window Screen-Cursor Shape

✓ We can use the following GLUT routine to request a shape for the screen cursor that is to

be used with the current window:

glutSetCursor (shape);

where, shape can be

➔ GLUT_CURSOR_UP_DOWN : an up-down arrow.

➔ GLUT_CURSOR_CYCLE: A rotating arrow is chosen

➔ GLUT_CURSOR_WAIT: a wristwatch shape.

➔ GLUT_CURSOR_DESTROY: a skull and crossbones

Viewing Graphics Objects in a GLUT Display Window

✓ After we have created a display window and selected its position, size, color, and other

characteristics, we indicate what is to be shown in that window

✓ Then we invoke the following function to assign something to that window:

glutDisplayFunc (pictureDescrip);

✓ This routine, called pictureDescrip for this example, is referred to as a callback function

because it is the routine that is to be executed whenever GLUT determines that the

display-window contents should be renewed.

✓ We may need to call glutDisplayFunc after the glutPopWindow command if the display
window has been damaged during the process of redisplaying the windows.

✓ In this case, the following function is used to indicate that the contents of the current

display window should be renewed:

glutPostRedisplay ( );

Executing the Application Program

✓ When the program setup is complete and the display windows have been created and

initialized, we need to issue the final GLUT command that signals execution of the

program:

glutMainLoop ( );

Other GLUT Functions

✓ Sometimes it is convenient to designate a function that is to be executed when there are

no other events for the system to process. We can do that with

glutIdleFunc (function);

✓ Finally, we can use the following function to query the system about some of the current

state parameters:

glutGet (stateParam);

✓ This function returns an integer value corresponding to the symbolic constant we select

for its argument.

✓ For example, for the stateParam we can have the values

➔ GLUT_WINDOW_X: obtains the x-coordinate position for the top-left corner of the

current display window

➔ GLUT_WINDOW_WIDTH or GLUT_SCREEN_WIDTH : retrieve the current

display-window width or the screen width with

Sep2020
3a. Classify the polygons and describe fill area primitives with diagrams.
(Repeat)
b. Describe about Inside-Outside Tests. (Repeat)
4a. Explain general scan line fill algorithm. (Repeat)
b. Describe any two of dimensional composite transformation
i) 2D translation ii) 2D fixed point scaling. (I don’t understand )
July2019
3a. Explain scan-line polygon fill algorithm. (Repeat) Determine the content
of the active edge table to fill the polygon with vertices A(2,4), B(4,6) and
C(4,1) for y=1 to y=6
b. Develop composite homogenous transformation matrix to rotate an object
w.r.t a pivot point.

For the triangle A(3,2), B(6,2), C(6,6) rotate it in anticlock-wise direction by


90degree keeping a(3,2) fixed, draw the new polygon.
4a. Explain the data structure used by scan line polygon fill algorithm.

The data structure used in the scan line polygon fill algorithm is a table or an array called the edge
table (ET). The edge table stores information about the edges of the polygon, such as their starting
and ending points and their slopes. Each row in the edge table corresponds to an edge of the
polygon, and the columns contain the following information:

1. Ymax: the maximum y-coordinate of the edge

2. Ymin: the minimum y-coordinate of the edge

3. X: the x-coordinate of the intersection of the edge with the scan line

4. Inverse slope: the inverse slope of the edge

In addition to the edge table, the algorithm also uses an active edge table (AET), which is a linked list
that stores the edges that intersect the current scan line. The edges in the AET are sorted by their x-
coordinates.

During the polygon fill process, the algorithm starts at the topmost scan line that intersects the
polygon and moves downwards. At each scan line, the algorithm updates the edges in the AET and
fills the pixels between the x-coordinates of each pair of edges. The algorithm also removes edges
from the AET when they reach their maximum y-coordinate.

The edge table is an efficient data structure for the scan line polygon fill algorithm because it allows
for quick access to the edges of the polygon and their properties. The AET is also efficient because it
only stores the edges that intersect the current scan line, reducing the amount of memory needed
for the algorithm.

Determine the content of active edge table to fill polygon with vertices
A(2,4), B(2,7), C(4,9) and D(4,6).
b. Give the reason to convert transformation matrix to homogenous
coordinate representation and show the process of conversion. (Repeat)
Shear the polygon A(1,1), B(3,1), C(3,3) D(2,4), E(1,3) along x-axis with
shearing factor of 0.2.
(Wronggggggggggg)

c. i) Prove that two successive 2D rotation are additive (Repeat)


ii) Prove that successive scaling are multiplicative. (Repeat)
Jan 2020
3a. Explain with example any two algorithm used to identify interior area of a
polygon. (Repeat)
b. Explain with illustrations the basic 2D geometric transformations used in
CG. (Repeat)
C. Explain the different OpenGL routines used for manipulating display
window. (Repeat)
4a. Explain scan-line polygon fill algorithm. (Repeat) And also explain the use
of sorted edge table and active edge list.
The sorted edge table (ET) and active edge list (AET) are both data structures used in the scan line
polygon fill algorithm. They serve different purposes and work together to efficiently fill polygons
with a specified color.

The sorted edge table is an array or a table that stores information about the edges of the polygon,
such as their starting and ending points and their slopes. Each row in the edge table corresponds to
an edge of the polygon, and the columns contain the following information:

1. Ymax: the maximum y-coordinate of the edge

2. Ymin: the minimum y-coordinate of the edge

3. X: the x-coordinate of the intersection of the edge with the scan line

4. Inverse slope: the inverse slope of the edge

The edge table is sorted by the y-coordinate of the edges. Sorting the edges by y-coordinate is
important because it allows the algorithm to process the edges one scan line at a time, starting with
the topmost scan line that intersects the polygon.

The active edge list is a linked list that stores the edges that intersect the current scan line. The
edges in the AET are sorted by their x-coordinates. The AET is updated at each scan line, with edges
added or removed based on their intersection points with the current scan line.
The use of the sorted edge table and active edge list allows the algorithm to quickly and efficiently
fill polygons. By sorting the edges by y-coordinate, the algorithm can process the edges one scan line
at a time, which reduces the amount of processing needed. By sorting the edges in the AET by x-
coordinate, the algorithm can quickly determine the start and end points of each horizontal segment
to be filled.

In summary, the sorted edge table and active edge list are essential data structures in the scan line
polygon fill algorithm. The edge table stores information about the edges of the polygon, sorted by
y-coordinate, while the active edge list stores the edges that intersect the current scan line, sorted
by x-coordinate. Together, these data structures allow the algorithm to fill polygons efficiently and
accurately.

b. What is the need of homogenous coordinates? (Repeat) Give 2D


homogenous coordinate matrix for translation, rotation and scaling.
(Formula sheet)
c. Obtain a matrix representation for rotation of object about a specified
pivot in 2D (Repeat)
Jan 2023
4b. explain OpenGL raster transformation and OpenGL geometric
transformation functions
Raster transformations are applied to the final image produced by the
rendering pipeline. They control the way the image is displayed on the screen.
Some examples of raster transformations in OpenGL include:
 glViewport(): This function sets the viewport, which is the area of the
screen where the final image is displayed. It takes four arguments: the x
and y coordinates of the lower left corner of the viewport, and its width
and height in pixels.
 glScissor(): This function clips the final image to a specific region of the
screen. It takes four arguments: the x and y coordinates of the lower left
corner of the scissor box, and its width and height in pixels.
 glPixelZoom(): This function scales the final image up or down. It takes
two arguments: the horizontal and vertical zoom factors.
Geometric transformations, on the other hand, are applied to the objects
themselves before they are rasterized. They control the position, orientation,
and scale of the objects in the scene. Some examples of geometric
transformations in OpenGL include:
 glTranslatef(): This function translates an object along the x, y, and z
axes. It takes three arguments: the amount of translation in each
direction.
 glRotatef(): This function rotates an object around an axis. It takes four
arguments: the angle of rotation in degrees, and the x, y, and z
components of the axis.
 glScalef(): This function scales an object along the x, y, and z axes. It
takes three arguments: the scaling factors in each direction.

You might also like