--- ray/src/cv/bsdfrep.c 2021/09/07 20:13:13 2.35 +++ 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.35 2021/09/07 20:13:13 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);