[julia] add RITNUM to make code slightly more legible

This commit is contained in:
Lucas 2020-03-09 00:03:26 +00:00
parent fc9617b2b1
commit 9c4e5f2f88

23
julia.c
View File

@ -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