From cb69732f68c0bd46c1574de16ce1aee6f38e439b Mon Sep 17 00:00:00 2001 From: Brett Weiland Date: Tue, 11 Jun 2024 14:50:14 -0500 Subject: restarting --- animation/kernel.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 animation/kernel.c (limited to 'animation/kernel.c') diff --git a/animation/kernel.c b/animation/kernel.c new file mode 100644 index 0000000..9c99b2b --- /dev/null +++ b/animation/kernel.c @@ -0,0 +1,30 @@ +__kernel void basic_test() { + printf("this cores ID: (%lu, %lu)\n", get_global_id(0), get_global_id(1)); +} +double cosecant_single(double a, double b) { return a / tan(b); } +double secant_single(double a, double b) { return a / sin(b); } + +__kernel void render_frame(__global unsigned int *frame_output, + double x_step, double y_step, + double x_start, double y_start, + unsigned int iterations, unsigned int escape, double r) { + unsigned int iter; + + double x_cart = (get_global_id(0) * x_step) + x_start; + double y_cart = (get_global_id(1) * y_step) + y_start; + size_t img_index = (get_global_id(1) * get_global_size(1)) + get_global_id(0); + + + double x = sqrt(pow(x_cart, 2) + pow(y_cart, 2)); + double y = atan(y_cart / x_cart); + double next_x; + + for(iter = 0; iter < iterations; iter++) { + next_x = (r * cosecant_single(x, y)) + ((1 - r) * secant_single(x, y)); + y = (r * cosecant_single(y, x)) + ((1 - r) * secant_single(y, x)); + x = next_x; + if((pow(x, 2) + pow(y, 2)) >= escape) break; + } + + frame_output[img_index] = iter; +} -- cgit v1.2.3