CENSORE
This commit is contained in:
parent
383ee7b75c
commit
51c4db334f
331 changed files with 0 additions and 10296 deletions
|
@ -1,88 +0,0 @@
|
|||
# Mandelbrot Set
|
||||
|
||||
TODO
|
||||
|
||||
```
|
||||
___________________________________________________________
|
||||
|[-2,1] . |
|
||||
| .:. |
|
||||
| ::::: |
|
||||
| ...:::.. . |
|
||||
| :..:::::::::::::.... |
|
||||
| .:::::::::::::::::::' |
|
||||
| :::::::::::::::::::::::: |
|
||||
| :::::::::::::::::::::::::' |
|
||||
| :..:::. .:::::::::::::::::::::::::: |
|
||||
| .:::::::::. :::::::::::::::::::::::::: |
|
||||
| .. ::::::::::: :::::::::::::::::::::::::' |
|
||||
| ' ' '::':::::::::::'::::::::::::::::::::::::. |
|
||||
| ::::::::::: :::::::::::::::::::::::::: |
|
||||
| ':::::::' ::::::::::::::::::::::::::. |
|
||||
| ' ''' :::::::::::::::::::::::::' |
|
||||
| '::::::::::::::::::::::::' |
|
||||
| ''::::::::::::::::::::'' |
|
||||
| :::::::::::::::::::: |
|
||||
| ' ''::::::::'': |
|
||||
| .:::. |
|
||||
| ':::' |
|
||||
| : |
|
||||
|___________________________________________________[0.5,-1]|
|
||||
```
|
||||
|
||||
## Code
|
||||
|
||||
The following code is a simple [C](c.md) program that renders the Mandelbrot set into terminal (for demonstrative purposes, it isn't efficient or do any [antialiasing](antialiasing.md)).
|
||||
|
||||
```
|
||||
#include <stdio.h>
|
||||
|
||||
#define ROWS 30
|
||||
#define COLS 60
|
||||
#define FROM_X -2.0
|
||||
#define FROM_Y 1.0
|
||||
#define STEP (2.5 / ((double) COLS))
|
||||
|
||||
unsigned int mandelbrot(double x, double y)
|
||||
{
|
||||
double cx = x, cy = y, tmp;
|
||||
|
||||
for (int i = 0; i < 1000; ++i)
|
||||
{
|
||||
tmp = cx * cx - cy * cy + x;
|
||||
cy = 2 * cx * cy + y;
|
||||
cx = tmp;
|
||||
|
||||
if (cx * cx * cy * cy > 1000000000)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
double cx, cy = FROM_Y;
|
||||
|
||||
for (int y = 0; y < ROWS; ++y)
|
||||
{
|
||||
cx = FROM_X;
|
||||
|
||||
for (int x = 0; x < COLS; ++x)
|
||||
{
|
||||
unsigned int point =
|
||||
mandelbrot(cx,cy) + (mandelbrot(cx,cy + STEP) * 2);
|
||||
|
||||
putchar(point == 3 ? ':' : (point == 2 ? '\'' :
|
||||
(point == 1 ? '.' : ' ')));
|
||||
|
||||
cx += STEP;
|
||||
}
|
||||
|
||||
putchar('\n');
|
||||
|
||||
cy -= 2 * STEP;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue