A blog for C programs, notes and articles about C, the programming language.
Search This Blog
C Program for Reflection Transformation for Computer Graphics Lab
Reflection is one of the 2d transformation operations in computer graphics. Here i present a c program to implement reflection. The reflection transformation can be applied on any polygon given by user using this c program. Reflection of points is done which results is reflection of lines or polygons drawn from the points. The reflection transformation is sometimes called flipping or mirroring. Reflection of a polygon about horizontal axis is called vertical flip and reflection about vertical axis is called vertical flip. Whatever we call, flipping or reflecting it is producing mirror image about an axis. The following c program performs reflection transformation on given polygon about both axes.
#include<stdio.h>
#include<graphics.h>
int graDriver=DETECT,graMode;
int n,xs[100],ys[100],i;
int tempYaxis,tempXaxis;
void DrawFn()
{
for(i=0;i<n;i++)
line(xs[i],ys[i],xs[(i+1)%n],ys[(i+1)%n]);
}
void FlipV()
{
tempXaxis=getmaxy()/2;
for(i=0;i<n;i++)
ys[i]=tempXaxis+(tempXaxis-ys[i]);
No comments:
Post a Comment