
Importance and applications of graphic computing
Other applications of graphic computing:
- Interfaces with the user.
- Interactive graphing in business, technology and science.
- Cartography (maps, reliefs, rivers).
- Medicine.
- Sketches and designs assisted by computers, Example: AutoCAD.
- Multimedia Systems (conferences, videophone, distance teaching).
- Simulation for civil and military training.
- Animation of characters for the cinema and television.
Basic Algorithms of Bidimensional Graphs
1. Discretization of lines
- From the equation of the line, we can calculate points between the ends of a line and draw them on the screen.
- Given a segment according to its extremes (x1, y1) and (x2, y2), the equation of the line that joins them can be written as:

- Assuming that we have a certain putPixel function (...) that allows us to color a pixel on the screen, the C code of this first algorithm could be the following:

- A first defect of this code is that it is only valid if the x coordinate of the first end of the line is smaller than that of the second end.
- Earrings and order of the ends.
- Many algorithms assume that the segment is in the first quadrant.

- Another shortcoming of the previous code is that it only works well with small slopes, since with higher slope lines it leaves undesirable gaps.
- But the main problem is the use of floating point arithmetic, especially the multiplication of the inner loop, very expensive in CPU time.
2. Digital differential analyzer (DDA)
- Basic Incremental Algorithm:
- It is possible to eliminate the multiplication inside the loop if we observe that:


Examples:
- Draw a line from (1,1) to (6,3):
 
- Draw a line from (1,1) to (3,6):
 
- In this example I will show you the figure of an isosceles triangle made by the DDA lines made in C language by the DevC ++.


Own Source
https://steemitimages.com/DQmXvRxBVCXHGHSFwEjGTdTodgvogJ4e2kkBqN1KGSt9ako/10.png)
Discretization of Circumferences
- Equation of a circle centered at the origin: x2 + y2 = R2
- Explicit circumference equation: 
- It is possible to draw a quarter of a circle by increasing x from 0 to R in unit steps (the other rooms are obtained by symmetry), but large gaps appear when approaching R.
- Parametric equations: x = R·cos θ y = R·sen θ
- We avoid the gaps by increasing the angle θ from 0º to 90º.
Eight-sided symmetry:
- Given a circle centered on the origin and a point on it, we can easily get seven additional points to that.

-Algorithm of the midpoint.
- We consider only 45º of the circumference, the second octant, of x = 0 ax = y = R / √2.
- We will use the function circle_points (...) to complete the rest of the circle.
- The strategy consists of selecting which of two pixels is closest to the circumference, evaluating the function at the midpoint between two pixels.
- In the second octant, the next pixel choice is between pixel E and pixel SE, and it will be based again on a decision variable d:


Example:

Own Source
Now I'm going to show you a small drawing in which I use an algorithm to fill in, the DDA lines and the circumferences:

Own Source
This drawing uses a filling algorithm, which consists in passing the coordinates (x,y) where the painting will start, by parameter, then sending the color to be painted and finally the color of the edge of the figure, what will be the point where you will finish painting. It was done in DevC ++.

Bibliographic References:
- Website: http://graficacionheribertojesus.blogspot.com/p/61-instalar-evaluar-los-principales.html
- Book: Una Humilde Introducción a la Graficación por Computadora y Otras Yerbas. Eduardo Navas
I hope you enjoyed this content, see you soon.
