CENSORE
This commit is contained in:
parent
383ee7b75c
commit
51c4db334f
331 changed files with 0 additions and 10296 deletions
92
julia_set.md
92
julia_set.md
|
@ -1,92 +0,0 @@
|
|||
# Julia Set
|
||||
|
||||
TODO
|
||||
|
||||
```
|
||||
___________________________________________________________________
|
||||
| Julia Set for -0.34 - 0.63i :. |
|
||||
| ..':. .. |
|
||||
| '':.:''' .. .. |
|
||||
| :':::.. '' ::. .. :.' |
|
||||
| '::::. :: :::. . :.'': . |
|
||||
| ......':::.::.:: ...::.:::.::.. . |
|
||||
| :::::::::':'.':.::::::::':.::''::.. |
|
||||
| . '::::'':':::':'':::' ::'' ' |
|
||||
| ':. . .. ..::'::':::. ' :' |
|
||||
| . :: :' ::..::::::: ::: ':::.. ' |
|
||||
| :':::: '.:::::::::'.::::' '' |
|
||||
| .:::::' ':::::::::. ''::::'. |
|
||||
| :. '::::'.::::::::::. '::':.' |
|
||||
| . . '':::. ::: ::::::::'::' .:::: |
|
||||
| :':. ... ':::.:':::'' ' ' ''. |
|
||||
| ..:: .::::::...':.::::::.: |
|
||||
| :::...' '.::::::::'.: .:.:'::::'': |
|
||||
| '' :. : .:''':' :::'::':::. ' ' |
|
||||
| '::'': '' '::: ::''::::: |
|
||||
| :: ':. '' '':::.: |
|
||||
| ' ' ' ::.:.'.' |
|
||||
| ::' |
|
||||
| ' |
|
||||
|___________________________________________________________________|
|
||||
```
|
||||
|
||||
|
||||
# Code
|
||||
|
||||
The following code is a simple [C](c.md) program that renders given Julia set into terminal (for demonstrative purposes, it isn't efficient or do any [antialiasing](antialiasing.md)).
|
||||
|
||||
```
|
||||
#include <stdio.h>
|
||||
|
||||
#define ROWS 30
|
||||
#define COLS 70
|
||||
#define SET_X -0.36 // Julia set parameter
|
||||
#define SET_Y -0.62 // Julia set parameter
|
||||
#define FROM_X -1.5
|
||||
#define FROM_Y 1.0
|
||||
#define STEP (3.0 / ((double) COLS))
|
||||
|
||||
unsigned int julia(double x, double y)
|
||||
{
|
||||
double cx = x, cy = y, tmp;
|
||||
|
||||
for (int i = 0; i < 1000; ++i)
|
||||
{
|
||||
tmp = cx * cx - cy * cy + SET_X;
|
||||
cy = 2 * cx * cy + SET_Y;
|
||||
cx = tmp;
|
||||
|
||||
if (cx * cx * cy * cy > 10000000000)
|
||||
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 =
|
||||
julia(cx,cy) + (julia(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