Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

Q.No.

01
Suppose a triangle with points A(4,1), B(6,1) C(4,3). Find the
composite transformation matrix to transform this triangle into
A'(1,4), B'(1,2) C'(5,4)
Solution
To find the composite transformation matrix that transforms the triangle with points A(4,1), B(6,1),
C(4,3) into A'(1,4), B'(1,2), C'(5,4), we can follow these steps:
1. Determine the individual transformations required to map each point to its
corresponding point.
2. Multiply the transformation matrices to obtain the composite transformation matrix.
Let's start by finding the transformation matrix for each point:
For point A: To transform point A(4,1) to A'(1,4), we need to perform the following transformations:

1. Translation: (-3, 3) to move point A to the new position.


2. Reflection over the line y = x.
For point B: To transform point B(6,1) to B'(1,2), we need to perform the following transformations:

1. Translation: (-5, 1) to move point B to the new position.


2. Reflection over the line y = x.

For point C: To transform point C(4,3) to C'(5,4), we need to perform the following transformations:

1. Translation: (1, 1) to move point C to the new position.


2. Reflection over the line y = x.

Now, let's compute the transformation matrices for each of these transformations:

Now, let's calculate the composite transformation matrix by multiplying these


individual transformation matrices:
Q.No.02
Suppose a triangle with points A(0,0), B(0,1) C(1,0). Find the
homogeneous matrix to transform this triangle into A'(1,1),
B'(2,2) C'(3,1)

Solution
To find the homogeneous matrix M that transforms the triangle with vertices, A(0,0), B(0,1)
C(1,0) into A'(1,1), B'(2,2) C'(3,1) respectively, you can use the following steps:

1. Find the transformation that maps each vertex of the original triangle to its
corresponding vertex in the new triangle
2. Construct the homogeneous matrix M based on these transformations.

Let's proceed with step 1:

To map point A to A’, we need to translate it by (1,1)

To map point B to B’, we need to translate it by (2,1)

To map point C to C’, we need to translate it by (2,1)

Now, let's construct the homogeneous matrix M which represents the transformation that
maps points from one coordinate system to another. In this case, we're transforming points
from one triangle to another by translating them.

A homogeneous transformation in 2D can be represented by a 3x3 matrix. The first two


columns of the matrix represent the linear transformation (such as scaling or rotating), and the
last column represents the translation.

In our case, since we are only translating the points, the linear transformation part of the matrix
will be the identity matrix (since we are not scaling or rotating the points), and the translation
part will be the translation vector

The translation vector is simply the difference between the corresponding points in the two
triangles.

So, let's construct the homogeneous matrix step by step:


Liner Transformation Part:

Since there is no scaling or rotation involved, the linear transformation part of the matrix will
be the identity matrix:

Now, if you multiply this matrix with the homogeneous coordinates of each point in the
original triangle, you will obtain the transformed points. For example, for point A the
transformation would be:
Solution
Solution: I

As the matrix on right side for s(1,1) is identity matrix so if we


multiply translation matrix then no change will occur. That’s
why no need to multiply.
Solution: II

As two successive translations are additive so no need to make


matrix and multiply
Solution: III

No need to put value of angle as it is clear from matrix that both


sides are different
Solution: IV
QUESTION
develop mid point algorithm that scan converts a circle start at pixel location X=R, Y=0. assume
you are scan converting in clock wise direction. find equations along with what choices should
be made for the next pixel.

SOLUTION
To develop the midpoint algorithm for scan-converting a circle starting at pixel
location X=R, Y=0 in a clockwise direction, we first need to understand the general
idea behind the midpoint circle algorithm.

The midpoint circle algorithm is an efficient method for drawing circles in computer
graphics. It works by determining the positions of pixels along the circle's
circumference by analyzing the midpoint of regions between pixels. The algorithm
takes advantage of the circle's symmetry to avoid redundant calculations.

Here are the main steps of the midpoint circle algorithm:

1. Initialization: Set the initial point of the circle (X=R, Y=0) and calculate the initial
decision parameter.

2. Iteration: Repeat until the decision parameter indicates that the entire circle has
been traversed.

- Determine the next pixel based on the current decision parameter.

- Update the decision parameter based on the chosen pixel.

- Plot the chosen pixel.

Now, let's develop equations for the midpoint circle algorithm:

1. Decision Parameter:

- For a circle centered at the origin, the decision parameter (P) at pixel (x, y) is given
by:
- At each step, the decision parameter helps determine the next pixel position.

2. Next Pixel Choices:

- Based on the current decision parameter and the circle's symmetry, we have four
possible choices for the next pixel:

3. Update Decision Parameter:

- At each step, update the decision parameter using the following rules:

- If moving east (or southeast), increment x by 1.

- If moving south (or southwest), decrement y by 1.

- If moving southeast or southwest (crossing the diagonal), decrement both x and


y by 1.

By following these equations and rules, you can implement the midpoint circle
algorithm to scan-convert a circle starting at pixel location X=R, Y=0 in a clockwise
direction.
Question
Consider three different raster systems with resolutions of 640 by 480, 1280 by
1024, and 2560 by 2048.

(a) What size frame buffer (in bytes is needed for each of these systems to store
12 bits per pixel?

(b) How, much storage is required for each system if 24 bits per pixel are to be
stored?

Solution

To calculate the size of the frame buffer for each system, we need to consider the
resolution and the number of bits per pixel.

(a) Size of frame buffer for 12 bits per pixel:

1. For the system with a resolution of 640 by 480:

Total pixels = 640 * 480 = 307,200 pixels

Total bits = Total pixels * bits per pixel = 307,200 * 12 = 3,686,400 bits

Size of frame buffer = Total bits / 8 (since 1 byte = 8 bits)

= 3,686,400 / 8

= 460,800 bytes

2. For the system with a resolution of 1280 by 1024:

Total pixels = 1280 * 1024 = 1,310,720 pixels

Total bits = Total pixels * bits per pixel = 1,310,720 * 12 = 15,728,640 bits

Size of frame buffer = Total bits / 8


= 15,728,640 / 8

= 1,966,080 bytes

3. For the system with a resolution of 2560 by 2048:

Total pixels = 2560 * 2048 = 5,242,880 pixels

Total bits = Total pixels * bits per pixel = 5,242,880 * 12 = 62,914,560 bits

Size of frame buffer = Total bits / 8

= 62,914,560 / 8

= 7,864,320 bytes

(b) Size of frame buffer for 24 bits per pixel:

1. For the system with a resolution of 640 by 480:

Total bits = Total pixels * bits per pixel = 307,200 * 24 = 7,372,800 bits

Size of frame buffer = Total bits / 8

= 7,372,800 / 8

= 921,600 bytes

2. For the system with a resolution of 1280 by 1024:

Total bits = Total pixels * bits per pixel = 1,310,720 * 24 = 31,457,280 bits

Size of frame buffer = Total bits / 8

= 31,457,280 / 8

= 3,932,160 bytes

3. For the system with a resolution of 2560 by 2048:

Total bits = Total pixels * bits per pixel = 5,242,880 * 24 = 125,829,120 bits
Size of frame buffer = Total bits / 8

= 125,829,120 / 8

= 15,728,640 bytes

These calculations give the size of the frame buffer needed for each system for storing
either 12 bits per pixel or 24 bits per pixel.

Question
Suppose a rectangular window whose lower left-hand corner is at L(-3,1) and
upper right-hand corner is at R(2,6). Use the Ling-Barsky algorithm to clip the
following lines. Line A: (1,2) to (-2,3) Line B: (-4,3) to (-1,7) Line C: (-1,5) to (3,8)
please also Calculate the values of r for entering and leaving intersections. Clip
the line if needed.

To apply the Liang-Barsky algorithm, we need to first define the region of the window and
then check for intersections of each line with the window boundaries. The algorithm will
determine whether the line lies completely inside the window, partially inside, or completely
outside. If partially inside, it will clip the line accordingly.

Given:
Window lower left corner: L(-3, 1)
Window upper right corner: R(2, 6)
Let's denote the boundaries of the window
Left boundary: x = -3
Right boundary: x = 2
Bottom boundary: y = 1
Top boundary: y = 6
We'll use the Liang-Barsky algorithm to clip each line. The algorithm works by calculating the
values of r for entering and leaving intersections. Here are the steps:

Calculate the direction vector of the line (dx, dy) and the differences between the line's starting
point and the window boundaries (p1, p2, p3, p4)
Initialize values of r for entering (r_enter) and leaving (r_leave) intersections
Check against the window boundaries to calculate r_enter and r_leave
Clip the line using the calculated values of r_enter and r_leave
Line A: (1,2) to (-2,3)
Direction vector (dx, dy) = (-2 - 1, 3 - 2) = (-3, 1)
Differences:
p1 = -3 - (-3) = 0
p2 = 2 - 1 = 1
p3 = 1 - (-3) = 4
p4 = 6 - 2 = 4

We need to find the values of r for entering and leaving intersections

For entering intersection:


r_enter = max(0, 4/(-3)) = 0 (since denominator is negative)
For leaving intersection:
r_leave = min(1, 4/(3)) = 4/3
Since both r_enter and r_leave are within [0, 1], the line is partially inside the window
The clipped line segment for A remains the same: (1, 2) to (-2, 3)

Line B: (-4,3) to (-1,7)


Direction vector (dx, dy) = (-1 - (-4), 7 - 3) = (3, 4)
Differences:
p1 = -3 - (-3) = 0
p2 = 2 - (-4) = 6
p3 = 1 - 3 = -2
p4 = 6 - 3 = 3
We need to find the values of r for entering and leaving intersections.
For entering intersection:
r_enter = max(0, -2/3) = 0
For leaving intersection:
r_leave = min(1, 3/3) = 1
Since both r_enter and r_leave are within [0, 1], the line is partially inside the window.
The clipped line segment for B remains the same: (-4, 3) to (-1, 7).

Line C: (-1,5) to (3,8)

Direction vector (dx, dy) = (3 - (-1), 8 - 5) = (4, 3)


Differences:
p1 = -3 - (-1) = -2
p2 = 2 - (-1) = 3
p3 = 1 - 5 = -4
p4 = 6 - 8 = -2
We need to find the values of r for entering and leaving intersections.

For entering intersection:


r_enter = max(0, -4/4) = 0
For leaving intersection:
r_leave = min(1, -2/3) = 1
Since both r_enter and r_leave are within [0, 1], the line is partially inside the window
The clipped line segment for C remains the same: (-1, 5) to (3, 8).
Thus, all lines remain the same after clipping since they are all partially inside the window.

You might also like