From 9c4e5f2f885d39e9c5ef9e465ff3797e737fbf49 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 9 Mar 2020 00:03:26 +0000 Subject: [PATCH] [julia] add RITNUM to make code slightly more legible --- julia.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/julia.c b/julia.c index 692b16d..9981402 100644 --- a/julia.c +++ b/julia.c @@ -28,6 +28,8 @@ #include "fun.h" +#define RITNUM(c, i) (c[i].it - c[i].rit) + #define OPTSTRING "a:b:c:D:d:h:Ll:N:n:w:x:y:z:" struct color contour_color = { 0 }; @@ -129,7 +131,7 @@ julia_main(int argc, char *argv[]) light_intensity = 84.3L, displacement = 0, zoom = 1.0, - light, light_x, light_y, light_z, rit, sec_h, zx, zy; + light, light_x, light_y, light_z, rit, rn, sec_h, zx, zy; long long it, idx, ritnum; int palette_size = 720, width = 640, @@ -238,21 +240,20 @@ julia_main(int argc, char *argv[]) pnmout_header(stdout, width, height); for (i = 0; i < height; i++) { for (j = 0; j < width; j++) { - it = rescache[i * rescache_width + j].it; - rit = rescache[i * rescache_width + j].rit; + rn = RITNUM(rescache, i * rescache_width + j); - if (it < 0) + if (rescache[i * rescache_width + j].it < 0) color = contour_color; else { - ritnum = (it - rit) * density; + ritnum = rn * density; if (do_light) { long double lxrn, lyrn, l, lx, ly, lz; - lxrn = rescache[i * rescache_width + j + 1].it - - rescache[i * rescache_width + j + 1].rit; - lyrn = rescache[(i + 1) * rescache_width + j].it - - rescache[(i + 1) * rescache_width + j].rit; - lx = -sec_h * (lxrn - it + rit); - ly = sec_w * (lyrn - it + rit); + lxrn = RITNUM(rescache, + i * rescache_width + j + 1); + lyrn = RITNUM(rescache, + (i + 1) * rescache_width + j); + lx = -sec_h * (lxrn - rn); + ly = sec_w * (lyrn - rn); lz = sec_w * sec_h; l = sqrtl(lx * lx + ly * ly + lz * lz); light = (light_x * lx + light_y * ly