--- ray/src/cv/bsdfrep.c 2020/10/26 21:12:20 2.34 +++ ray/src/cv/bsdfrep.c 2021/12/15 01:38:50 2.37 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: bsdfrep.c,v 2.34 2020/10/26 21:12:20 greg Exp $"; +static const char RCSid[] = "$Id: bsdfrep.c,v 2.37 2021/12/15 01:38:50 greg Exp $"; #endif /* * Support BSDF representation as radial basis functions. @@ -104,7 +104,10 @@ new_input_direction(double new_theta, double new_phi) int use_symmetry(FVECT vec) { - const double phi = get_phi360(vec); + double phi = get_phi360(vec); + /* because of -0. issue */ + while (phi >= 360.) phi -= 360.; + while (phi < 0.) phi += 360.; switch (inp_coverage) { case INP_QUAD1|INP_QUAD2|INP_QUAD3|INP_QUAD4: @@ -225,10 +228,10 @@ rotate_rbf(RBFNODE *rbf, const FVECT invec) void ovec_from_pos(FVECT vec, int xpos, int ypos) { - double uv[2]; + RREAL uv[2]; double r2; - SDsquare2disk(uv, (xpos+.5)/grid_res, (ypos+.5)/grid_res); + square2disk(uv, (xpos+.5)/grid_res, (ypos+.5)/grid_res); /* uniform hemispherical projection */ r2 = uv[0]*uv[0] + uv[1]*uv[1]; vec[0] = vec[1] = sqrt(2. - r2); @@ -241,10 +244,10 @@ ovec_from_pos(FVECT vec, int xpos, int ypos) void pos_from_vec(int pos[2], const FVECT vec) { - double sq[2]; /* uniform hemispherical projection */ + RREAL sq[2]; /* uniform hemispherical projection */ double norm = 1./sqrt(1. + fabs(vec[2])); - SDdisk2square(sq, vec[0]*norm, vec[1]*norm); + disk2square(sq, vec[0]*norm, vec[1]*norm); pos[0] = (int)(sq[0]*grid_res); pos[1] = (int)(sq[1]*grid_res); @@ -478,7 +481,7 @@ e_advect_rbf(const MIGRATION *mig, const FVECT invec, double t, full_dist; /* get relative position */ t = Acos(DOT(invec, mig->rbfv[0]->invec)); - if (t < M_PI/grid_res) { /* near first DSF */ + if (t <= .001) { /* near first DSF */ n = sizeof(RBFNODE) + sizeof(RBFVAL)*(mig->rbfv[0]->nrbf-1); rbf = (RBFNODE *)malloc(n); if (rbf == NULL) @@ -488,7 +491,7 @@ e_advect_rbf(const MIGRATION *mig, const FVECT invec, return(rbf); } full_dist = acos(DOT(mig->rbfv[0]->invec, mig->rbfv[1]->invec)); - if (t > full_dist-M_PI/grid_res) { /* near second DSF */ + if (t >= full_dist-.001) { /* near second DSF */ n = sizeof(RBFNODE) + sizeof(RBFVAL)*(mig->rbfv[1]->nrbf-1); rbf = (RBFNODE *)malloc(n); if (rbf == NULL)