Date: Fri, 11 Dec 1998 11:44:44 -0500 (EST) From: David Nash X-Sender: dnash@pacman.rs.itd.umich.edu To: beale@BEST.COM Subject: Problem with orb (spherical heightfield generator) I think I've found a bug in the Unix (C source only) version of orb. I've been using it to make planets in POV-Ray, using actual altitude data from space missions. No problems compiling it, but I found that what I got out didn't resemble the image map used as input. The x-dimension (horizontal) of the image map maps correctly, but only the central part of the y-dimension (vertical) gets mapped. I've found what seems to be the problem: gsphere.c has the lines: r2d = sqrt(r.x * r.x + r.y * r.y); /* radius in the x-y plane */ phi = atan2(r.z,r2d); /* range of atan2 is [-pi..pi] */ theta = atan2(r.y, r.x); xmap = (int)((0.5 + pi2inv * theta) * (double)xsize); ymap = (int)((0.5 + pi2inv * phi) * (double)ysize); In gsphere.c phi will never range over more than two quadrants, since r2d is always positive. I.e., its range will be -pi/2 to pi/2. However, ymap assigns the top of the map to phi=-pi (instead of -pi/2) and the bottom (ysize) to phi=+pi -- meaning that only the central portion of the image map gets processed. Changing this line to ymap = (int)((0.5 + (pi2inv * phi * 2)) * (double)ysize); solves the problem. Sorry to bother you if you're already aware of this. Sincerely, David Nash dnash@umich.edu