/* Last edited on 2023-02-22 20:44:25 by stolfi */ /* ---------------------------------------------------------------------- */ void irt_butterfly_from_ia_diff (IntervalDiff *fd, ia_butfly_t *ip); /* Computes a bounding butterfly {ip} from the ranges {fd->f} and {fd->df} of a function and its derivative. */ void irt_butterfly_from_ia_diff (IntervalDiff *fd, ia_butfly_t *ip) { ip->yxlo = ip->yxmd = ip->yxhi = fd->f; ip->xmd = 0.0; if (fd->df.lo > 0.0) { /* Function is strictly increasing */ ROUND_UP; ip->yxlo.hi = ip->yxhi.hi - fd->df.lo; ROUND_DOWN; ip->yxhi.lo = ip->yxlo.lo + fd->df.lo; } else if (fd->df.hi < 0.0) { /* Function is strictly decreasing */ ROUND_UP; ip->yxhi.hi = ip->yxlo.hi + fd->df.hi; ROUND_DOWN; ip->yxlo.lo = ip->yxhi.lo - fd->df.hi; } else { /* Function may be increasing or decreasing, can't say anything */ } } /* ---------------------------------------------------------------------- */ typedef struct cmp_int_data_t { /* Parameters passed to irt_compute_intersection: */ shape_t *sh; h3_point_t *org; h3_point_t *dst; Interval *hit; int *slo; int *shi; int print_ray; } cmp_int_data_t; /* ---------------------------------------------------------------------- */ Interval zf_trapezoid_slice_yrange(Interval *xo, Interval *xi, Interval *yxlor, Interval *yxhir) { Float alo, ahi, blo, bhi; if (ip->lox.lo >= Zero) { ROUND_DOWN; alo = ((One - e)/Two)*ip->yxlo.lo;} else { ROUND_UP; alo = -(((One - e)/Two)*(-ip->yxlo.lo)); } if (yxhi.lo >= Zero) { ROUND_DOWN; blo = ((One + e)/Two)*yxhi.lo;} else { ROUND_UP; blo = -(((One + e)/Two)*(-yxhi.lo)); } if (ip->yxlo.hi >= Zero) { ROUND_UP; ahi = ((One - e)/Two)*ip->yxlo.hi;} else { ROUND_DOWN; ahi = -(((One - e)/Two)*(-ip->yxlo.hi)); } if (yxhi.hi >= Zero) { ROUND_UP; bhi = ((One + e)/Two)*yxhi.hi;} else { ROUND_DOWN; bhi = -(((One + e)/Two)*(-yxhi.hi)); } ROUND_DOWN; f_trp.lo = alo + blo; ROUND_UP; f_trp.hi = ahi + bhi; } /* ---------------------------------------------------------------------- */ /* double xc = 4.25 * 72.0; */ /* double hmin = xc - size / 2.0; */ /* double hmax = xc + size / 2.0; */ /* double yc = 6.50 *72.0; */ /* double vmin = yc - size / 2.0; */ /* double vmax = yc + size / 2.0; */ /* ---------------------------------------------------------------------- */ else if (strcmp(t, "proc_name") == 0) { sc->shape.proc_name = irt_read_name(); } else if (strcmp(t, "print_ray") == 0) { sc->print_ray = irt_read_pixel_num(); } else if (strcmp(t, "plot_ray") == 0) { sc->plot_ray = irt_read_pixel_num(); } else if (strcmp(t, "image_width") == 0) { sc->view.image_width = irt_read_int32_t(); } else if (strcmp(t, "image_height") == 0) { sc->view.image_height = irt_read_int32_t(); } else if (strcmp(t, "pixel_size") == 0) if (strcmp(t, "arithmetic") == 0) { char *a = strtok(NULL, " "); if (strcmp(a, "IA") == 0) { sc->arithmetic = arith_ia; } else if (strcmp(a, "IA/DIFF") == 0) { sc->arithmetic = arith_ia_diff; } else if (strcmp(a, "AA") == 0) { sc->arithmetic = arith_aa; } else if (strcmp(a, "MIX") == 0) { sc->arithmetic = arith_mix; } else { fatalerror ("irt_read_parm_file: unknown arithmetic"); } } else char *proc_name; /* Name of function that defines the scene's shape */ char *scene_dir = o->scene_dir; char *scene_name = o->scene_name; o->scene_dir = argparser_get_next(pp); o->scene_name = argparser_get_next(pp); if (sc->shape.proc_name == NULL) { fatalerror ("irt_read_parm_file: missing parameter proc_name"); } char *irt_read_name(void); /* Parses an identifier. */ pixel_num_t irt_read_pixel_num(void); /* Parses a pair of pixel indices (row and col). */ char *irt_read_name(void) { return(txtcat(strtok(NULL," "), "")); } pixel_num_t irt_read_pixel_num(void) { pixel_num_t p; p.col = irt_atoi(strtok(NULL, " ")); p.row = irt_atoi(strtok(NULL, " ")); return(p); } /* ---------------------------------------------------------------------- */