Translation of line comes under the category of geometric transformations.In geometric transformations,the object is transformed relative to a stationary coordinate system or background.In 2D translation,the object is displaced along x and y direction and magnitude of displacement is specified by translation parameters tx and ty. In order to perform a sequence of transformations(translation,scaling,rotation or reflection) […]

# C

# Cohen Sutherland Line Clipping Algorithm

Line Clipping Algorithms are used for clipping line with respect to a rectangle called as clipping window. Cohen Sutherland line clipping algorithm checks both the endpoints with four boundaries of rectangle(top,bottom,left and right) to decide whether the point lies inside or outside the four boundaries.This checking is done using a four bit code corresponding to […]

# Boundary-Fill Algorithm

Boundary-fill algorithm is used for region filling when the region is boundary-defined i.e. pixels having colour equal to boundary_col comprise the boundary of region.This algorithm starts with a seed pixel inside the region which is the starting point for the recursive algorithm. The algorithm checks to see if pixel is boundary pixel(defined by boundary_col) or […]

# Flood-Fill Algorithm

Flood-fill algorithm is used for region filling when the region is interior-defined i.e. when all the pixels in the region have same colour(old_col).This algorithm starts with a seed pixel inside the region which is the starting point for the recursive algorithm. The algorithm checks to see if colour of pixel is same as original colour […]

# Mid-Point Ellipse Drawing Algorithm

Mid-Point Ellipse Drawing Algorithm algorithm uses symmetry of ellipse and mid point algorithm is implemented for one quadrant only.We divide the quadrant into two regions and the boundary of two regions is the point at which the curve has a slope of -1. We process by taking unit steps in the x direction to the […]

# Mid-Point Circle Drawing Algorithm

Mid-Point Circle Drawing algorithm is based on determining subsequent points for drawing a circle.This algorithm also uses the concept of symmetry between octants of a circle. So, we need to use this algorithm on one octant only.Corresponding points in other octants can be plotted using concept of symmetry between octants. #include<stdio.h> #include<conio.h> /*Header file for […]

# DDA Line Drawing Algorithm

DDA(Digital DIfferential Analyzer) is a simple line drawing algorithm.It is based on calculating the difference between x and y coordinates of two points and determining which of the two directions need more steps. #include<stdio.h> #include<conio.h> /*Header file for built-in graphics functions such as plot() and initgraph()*/ #include<graphics.h> #include<math.h> int round(float val) { return (int)(val+0.5); } […]

# Bresenham’s Line Drawing Algorithm

The Bresenham algorithm is a basic line drawing algorithm. It uses only integer calculations. At every step,we move one unit in x direction and choose among two candidate points in y direction. #include<stdio.h> #include<conio.h> /*Header file for built-in graphics functions such as plot() and initgraph()*/ #include<graphics.h> /* Function To Implement Bresenham’s algorithm */ void line_bresenham(int […]

# Executing System Commands Using C++ code

System commands can be exexuted using C++. Sometimes it is needed when some information about the system is to be gathered by the program or some other task needs to be performed. Here’s the code that can be used to execute system commands using C++. /* system example : DIR */ #include <stdio.h> /* printf […]

# C Code to Generate Map of India

This obfuscated C code can be used to generate the Map of India. Read more about obfuscated code here. https://en.wikipedia.org/wiki/Obfuscation_(software) Here’s the output that would be generated.