0% found this document useful (0 votes)
59 views27 pages

Final

The document discusses 10 lectures on 2D and 3D transformations. It covers the main types of transformations like translations, rotations, scaling, shearing and reflections. It provides the mathematical formulas to perform each transformation in 2D and 3D. It also discusses techniques for polygon clipping like Sutherland Hodgeman algorithm and Weiler Atherton algorithm. The lectures explain concepts like homogeneous coordinates that make it easier to compose translations and rotations through matrix multiplications.

Uploaded by

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

Final

The document discusses 10 lectures on 2D and 3D transformations. It covers the main types of transformations like translations, rotations, scaling, shearing and reflections. It provides the mathematical formulas to perform each transformation in 2D and 3D. It also discusses techniques for polygon clipping like Sutherland Hodgeman algorithm and Weiler Atherton algorithm. The lectures explain concepts like homogeneous coordinates that make it easier to compose translations and rotations through matrix multiplications.

Uploaded by

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

Lecture -1

Transformation

Transformation means to change. There are 4 main types of transformations that one can
perform in 2 dimensions.

1. Translations
2. Rotation
3. Scaling
4. Shearing
5. Reflection

Translation : Translation moves the object form one position to another position
in a straight line
Roation

x=rcos..... (1)
y=rsin...... (2)

Same way we can represent the point P (X, Y) as

x=rcos(+) = rcoscos rsinsin.......(3)


y=rsin(+)= rcossin + rsincos.......(4)

Substituting equation (1) & (2) in (3) & (4) respectively, we will get

x=xcosysin
y=xsin+ycos

P = P . R

Where R is the rotation matrix

For Anticlockwise rotation ( Positive Rotation )

For Clockwise rotation ( Negative Rotation ) replace by


In the previous question fix the center of the square and perform the same rotation
Lecture -2
Shear
A transformation that slants the shape of an object is called the shear
transformation. There are two shear transformations X-Shear and Y-Shear. One
shift X coordinates values and other shifts Y coordinate values. Shearing is also
termed as Skewing.

X-Shear

The X-Shear preserves the Y coordinate and changes are made to X coordinates

X' = X + Shx. Y

Y = Y

Y-Shear

The Y-Shear preserves the X coordinates and changes the Y coordinates

Y = Y + Shy . X

X = X
Reflection

Note that there are two angles between the lines, an acute one and an obtuse one. To find
acute angle b/w lines

Slope of line b/w two points


Similarly You can think about others like Rotation ,Scaling, Shearing, Reflection .
Lecture -3
Clipping and Viewing

Sometimes the complete picture of object in the world coordinate system is too large and
complicate to clearly show on the screen, and we need to show only some part of the object.

To do so we take the help of window. A Window is a rectangular region in the world


coordinate system.

When a window is "placed" on the world, only certain objects and parts of objects can be
seen. Points and lines which are outside the window are "cut off" from view. This process of
"cutting off" parts of the image of the world is called Clipping.

The scale factors ( Sx, Sy ) would be:


Xv Xvmin Xvmax - Xvmin
---------------- = ---------------------
Xw - Xwmin Xwmax - Xwmin

Yv - Yvmin Yvmax - Yvmin


---------------- = ---------------------
Yw - Ywmin Ywmax - Ywmin

Q. Let the co-ordinates of point in real world are (6,8 ) .What are its coordinates
in viewport .The widow size is given in diagram for both Real World and
Viewport

10,10

4,4

Real World

20,20

15,15
15,15 ViewPort
Clipping

Point Clipping :-
Lecture -4

Line Clipping :- Portion Outside the window is clipped

Cohen Sutherland Algo : -

It is used to fast the clipping process

4 bit code
If both the endpoints have code 0000 : Draw complete line

If Code of one end point And Operation Code of other end point = Non Zero,
it means line is completely outside the window . Clip it completely

If Code of one end point And Operation Code of other end point = Zero, it
means line is completely outside the window or line is partially inside partially
outside the window .
Lecture -5,6

Mid Point Subdivision Algorithm

Like Cohen Sutherland Algo line is tested for visibility. If the line is completely
visible it is drawn and if it is completely invisible it is rejected.

The difference between these two algorithms is that in Cohen Sutherland Algo
we have to calculate the intersection of line with the window edge . These
calculations can be avoided by repetitively subdividing the line at its midpoint
.The visibility test are then applied to each half. This subdivision process is
repeated until we get completely visible or completely invisible line segment

The midpoint subdivision algorithm requires repeated subdivision of line


segments and hence many times it is slower than using direct calculation of the
intersection of line with the clipping window edge. However it can be
implemented efficiently using Parallel architecture since it involves parallel
operations
Liang-Barsky Line Clipping Algorithm

We will be using parametric equation of line

We know point lies inside the window if


Initially we know t1=0, t2=1 .

Check the value of p .

If any p value is zero then line is parallel to the window (may be inside, may be outside,
may be on boundary) .Check the corresponding q

q<0 (line is outside therefore no need to move further )


q >0 (line is inside/partially inside)
q=0 (line is within boundary / partially within boundary )
Procedure

For all pk< 0 (The point is called potentially entering point ) find t1

t1=Max( 0 , qk / pk )

For all pk> 0 (The point is called potentially leaving point ) find t2

t2= Min (1, qk / pk )

Once you get t1 and t2 check If t1 > t2 then line is completely outside therefore
reject
Otherwise find the intersection points as
Lecture -7
Lecture -8

Sutherland Hodgeman Polygon Clipping Algorithm


We know

1. Clipping of a polygon is also a polygon


2. If we know vertices of polygon after clipping in clockwise or anticlockwise order than
we can draw the polygon .To obtain the same (vertices in clockwise or anticlockwise order )
we use the concept discussed in point No .3
3. For the given polygon start from any edge and move in clockwise or anticlockwise order
until we finish all the edges of polygon and observe the following 4 conditions

Starting vertex of edge is never saved, we will be saving only intersection point (always )
and last vertex (if it lies inside clipping window)

Weiler-Atherton Polygon Clipping Algorithm (Already discussed in class)


Lecture -9

1) Translations
2) Rotation
3) Scaling
4) Shearing
5) Reflection

Translation
Rotation ( About any axis )

Where an object is to be rotated about an axis that is parallel to one of the


coordinate axis. Z-axis rotation is same as the origin about in 2D for which we
have the derived

Obtain rotations around other axes through cyclic rotation


Scaling

New volume = (2*3*4) * old Value

Shearing ( About Plane )

About xy plane i.e z=0 plane


x= x+ Shx z
y= y + Shy z
z=z
Reflection

About any axis

Reflection about x-axis:-


x=x y=-y z=-z
Reflection about y-axis:-
x=-x y=y z=-z
Reflection about z-axis:-
x=-x y=-y z=z

About Plane

Reflection about xy plane i.e z=0 plane


x=x y= y z=-z
Reflection about yz plane i.e x=0 plane
x= - x y= y z=z

Reflection about xz plane i.e y=0 plane


x= x y= - y z=z
Lecture -10

3D Homogeneous Coordinate

We don't lose anything

The main advantage: it is easier to compose translation and rotation

Everything is matrix multiplication

You might also like