blob: b76da0b0ff1823c09064da9a84e80b8719d9cb19 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
#include "util.h"
/*
* Converts a grid point into an complex number
*/
double complex lattice_to_complex(const size_t index, const vec2 resolution) {
const double x_min = -2.0;
const double x_max = 2.0;
const double y_min = -2.0;
const double y_max = 2.0;
const double x_step = (x_max - x_min) / (double)resolution.x;
const double y_step = (y_max - y_min) / (double)resolution.y;
const size_t x_index = index % resolution.x;
const size_t y_index = index / resolution.x;
const double x = x_min + x_index * x_step;
const double y = y_min + y_index * y_step;
return x + y * I;
}
|