[julia] add RITNUM to make code slightly more legible
This commit is contained in:
parent
fc9617b2b1
commit
9c4e5f2f88
23
julia.c
23
julia.c
@ -28,6 +28,8 @@
|
|||||||
|
|
||||||
#include "fun.h"
|
#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:"
|
#define OPTSTRING "a:b:c:D:d:h:Ll:N:n:w:x:y:z:"
|
||||||
|
|
||||||
struct color contour_color = { 0 };
|
struct color contour_color = { 0 };
|
||||||
@ -129,7 +131,7 @@ julia_main(int argc, char *argv[])
|
|||||||
light_intensity = 84.3L,
|
light_intensity = 84.3L,
|
||||||
displacement = 0,
|
displacement = 0,
|
||||||
zoom = 1.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;
|
long long it, idx, ritnum;
|
||||||
int palette_size = 720,
|
int palette_size = 720,
|
||||||
width = 640,
|
width = 640,
|
||||||
@ -238,21 +240,20 @@ julia_main(int argc, char *argv[])
|
|||||||
pnmout_header(stdout, width, height);
|
pnmout_header(stdout, width, height);
|
||||||
for (i = 0; i < height; i++) {
|
for (i = 0; i < height; i++) {
|
||||||
for (j = 0; j < width; j++) {
|
for (j = 0; j < width; j++) {
|
||||||
it = rescache[i * rescache_width + j].it;
|
rn = RITNUM(rescache, i * rescache_width + j);
|
||||||
rit = rescache[i * rescache_width + j].rit;
|
|
||||||
|
|
||||||
if (it < 0)
|
if (rescache[i * rescache_width + j].it < 0)
|
||||||
color = contour_color;
|
color = contour_color;
|
||||||
else {
|
else {
|
||||||
ritnum = (it - rit) * density;
|
ritnum = rn * density;
|
||||||
if (do_light) {
|
if (do_light) {
|
||||||
long double lxrn, lyrn, l, lx, ly, lz;
|
long double lxrn, lyrn, l, lx, ly, lz;
|
||||||
lxrn = rescache[i * rescache_width + j + 1].it
|
lxrn = RITNUM(rescache,
|
||||||
- rescache[i * rescache_width + j + 1].rit;
|
i * rescache_width + j + 1);
|
||||||
lyrn = rescache[(i + 1) * rescache_width + j].it
|
lyrn = RITNUM(rescache,
|
||||||
- rescache[(i + 1) * rescache_width + j].rit;
|
(i + 1) * rescache_width + j);
|
||||||
lx = -sec_h * (lxrn - it + rit);
|
lx = -sec_h * (lxrn - rn);
|
||||||
ly = sec_w * (lyrn - it + rit);
|
ly = sec_w * (lyrn - rn);
|
||||||
lz = sec_w * sec_h;
|
lz = sec_w * sec_h;
|
||||||
l = sqrtl(lx * lx + ly * ly + lz * lz);
|
l = sqrtl(lx * lx + ly * ly + lz * lz);
|
||||||
light = (light_x * lx + light_y * ly
|
light = (light_x * lx + light_y * ly
|
||||||
|
Loading…
Reference in New Issue
Block a user