aboutsummaryrefslogtreecommitdiff
path: root/algorithms/burning-ship.c
blob: bfbd0a7b3c53f06478650744fd60e6c5b11bbf46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "../fractal-gen.h"

void *generate_burning_ship_section(void *section)
{
	data_section *d = (data_section*)section;
	unsigned int x,y,i;
	int idx = 0;
	double a,b;
	double complex z,c;
	double size_units = 3.5f;
	double top = -2.2f;
	double left = -2.2f;

	for (y = d->core, b = (d->core*(size_units/d->size)+top); y < d->size; b+=((d->cores*size_units)/d->size), y+=d->cores)
	{
		for (x = 0, a = left; x < d->size; a+=(size_units/d->size), x++)
		{
			z = 0;
			c = a+I*b;
			for (i = 0; i < d->iterat; i++)
			{
				if (cabsf(z) >= 2)
					break;

				z = cpow( cabsf(crealf(z)) + I*cabsf(cimagf(z)) , d->power) + c;
			}
			d->data[idx++] = (255*i)/d->iterat;
		}
	}
	return NULL;
}