Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!lll-crg!seismo!mcvax!ukc!icdoc!qmc-cs!liam From: liam@cs.qmc.ac.uk (William Roberts) Newsgroups: net.graphics Subject: Re: Ray Trace problems Message-ID: <182@cs.qmc.ac.uk> Date: Thu, 7-Aug-86 12:10:24 EDT Article-I.D.: cs.182 Posted: Thu Aug 7 12:10:24 1986 Date-Received: Sun, 10-Aug-86 20:04:56 EDT References: <220@joevax.UUCP> Reply-To: liam@cs.qmc.ac.uk (William Roberts) Organization: CS Dept, Queen Mary College, University of London, UK. Lines: 48 Keywords: raytrace, floating-point addition Expires: Sender: Xpath: ukc eagle In article <220@joevax.UUCP> sdh@joevax.UUCP writes: >Question: is the resolution of the output supposed to 450 x 450, >and are the pixels supposed to be non-square? >I plotted the data on a macintosh(square pixels) using a routine to >simulate gray level. What it displayed looked like a grid on an angle >with one squashed sphere. The pixels are supposed to be square, but the image is actually 451 x 451 and not 450 x 450 as advertised. Using 450 pixels per row causes the image to appear slanted, as you say. Q: Why 451 and not 450? A: Look at the code (in tracer.c): #define XMIN 100.0 #define XMAX 250.0 #define YMIN 30.0 #define YMAX 180.0 #define INC 0.333333333333 main () { static float xco, yco; for (xco = XMIN; xco < XMAX; xco += INC) { for (yco = YMIN; yco < YMAX; yco += INC) { /* generate a pixel */ } } INC is actually LESS than 1/3, so even if you dont lose precision on the repeated addition, 450 * INC is going to be to be less than 150. Change this to read #define INC 0.333333333334 or calculate xco and yco from an integer pixel coordinate if you really want 450 x 450 images. The result is very nice - it took 6:37 minutes on our VAX 11/750 and a mere 38 minutes on our Sequent Balance 8000. -- William Roberts ARPA: liam@cs.qmc.ac.uk (gw: cs.ucl.edu) Queen Mary College UUCP: liam@qmc-cs.UUCP LONDON, UK Tel: 01-980 4811 ext 3900