Polygon clipping is one of the classic problem in computer graphics lab. Generally, polygons or whatever objects, are clipped by a rectangular clipping windows. But, this one is a little more challenging graphics lab experiment in which we have to clip polygon with another polygon. That is the clipping windows is actually another polygon. The following c program implements polygon clipping with another polygon. The program clips any polygon with the clipping polygon, given both should be convex polygons.
Search This Blog
Showing posts with label polygon. Show all posts
Showing posts with label polygon. Show all posts
C Program for Shear Transformation - Shear Transformation in 2D Computer Graphics
Shear transformation or shearing is one of the 2d transformations in computer graphics. Here i present a c program for shear transformation of polygons. The shear transformation works as follows:
For shearing along X axis, shearfactor* (y coordinate) is added with x co-ordinates of all points. That is:
Similarly, to shear along Y axis, we add shearfactor* (x coordinate) to y co-ordinates of all points.
For shearing along X axis, shearfactor* (y coordinate) is added with x co-ordinates of all points. That is:
newx=oldx+shearfactor*oldy
Similarly, to shear along Y axis, we add shearfactor* (x coordinate) to y co-ordinates of all points.
newy=oldy+shearfactor*oldx
C Program for Rotation of Polygon - 2D Transformation in Computer Graphics
This is a c program for rotation transformation in computer graphics. Rotation is one of the important 2d transformations in computer graphics. The program will tell you how to rotate points or polygon around a point (the pivot point). This CG lab program in c language using the graphics library reads the number of sides of polygon, co-ordinates of its vertices, the pivot point for rotation, and angle of rotation. It displays the original polygon and rotated polygon in different colors in same screen. More Computer graphics lab problems are available under related posts heading.
C Program for Translation 2D Transformation in Computer Graphics
This is a c program for translation transformation in computer graphics. Translation (or shifting) is a very basic 2d transformation operation in computer graphics. Translation or shifting is done by adding the distance to shifted to the co-ordinates. For example, if we want to shift a polygon 50 units (pixels) horizontally, we just have to add 50 to x co-ordinates of all vertices of the polygon. Similarly, if it is translate only vertically by 100 unit, add 100 to y co-ordinates of all vertices. This CG lab program in c language using the graphics library reads the number of sides of polygon, co-ordinates of its vertices and the translation distance along both axes. It displays the original polygon and translated polygon in different colors in same screen. This is only a very simple and basic Computer graphics lab problem.
Subscribe to:
Posts (Atom)