From: erich@eye.com (Eric Haines)
Newsgroups: comp.graphics
Subject: Graphics Gems II errata
Date: Fri, 25 Sep 92 17:30:26 GMT
Organization: 3D/EYE, Inc.  Ithaca, NY

Attached is an errata listing for Graphics Gems II.  Please send me any other
errors you've discovered.  Corrected code should be available by FTP soon.

Eric Haines  erich@eye.com



Errata to _Graphics Gems II_, first edition, edited by Jim Arvo
(arvo@graphics.cornell.edu), Academic Press 1991.  Code available online in
princeton.edu:pub/Graphics/GraphicsGems/GemsII.

compiled by Eric Haines (erich@eye.com) from author and reader contributions

version 1.0
date:  9/25/92

-----

Errors in the text:

p. xxix, middle of page:  change "Rod G. Bogart (72)" to
		"Rod G. Bogart (72, 181)"

p. 249, last sentence:  change "less than 0, then" to "less than tnear, then"

-----

The following are errors in the code listings (corrected in the online code at
princeton.edu:pub/Graphics/GraphicsGems/GemsII).  Note that many of the code
listings online are different in minor and major ways from the code in the
book (see Addenda, at the end, for new code not in the book).


Serious errors (ones your compiler cannot or may not catch):

p. 572, line 27:  change "struct epthbuf_el {" to "struct depthbuf_el {"
p. 574, 4th line from bottom:  delete "break;" statement in order to move to
	next pair of edges

p. 576, line 28:  change "if ( t < 0.0 )" to "if ( t < tnear )"

p. 591, line 7:  change "*fp ==1.0;" to "*fp = 1.0;"

-----

Syntax errors (ones your compiler or lint will catch):

p. 458-466, throughout:  replace "};" with "}" to make lint happy
p. 464, gcd():  the variable "k" is set but not used - remove it

p. 477, line 11 and p. 478, lines 15,18:  change "coord" to "gcoord" and
		"last_coord" to "glast_coord" to avoid same name use for
		global and local variables
p. 477, line 20:  delete ", pos=0", since "pos" is not used in code.
p. 483, v_convert code:  change "alpha" to "alph", since "alpha" is a global
		defined in "types.h"

p. 543, 547, 548:  comment out text after "#else" and "#endif" statements
	(some compilers don't like this)

p. 550, line 21:  change "int i, num_iterations = 0;" to
		"int num_iterations = 0 ;", as "i" is not used
p. 551, 2nd line from bottom:  delete line "Matrix3 *vm;", as "vm" is not used
p. 559, line 14:  delete "int i;" declaration; "i" not used

p. 573, line 15:  delete "static" declaration from shadepoly

p. 581 throughout:  code is mostly for illustrative purposes; the RAY_REC,
	LIGHT_REC, TRIANGLE_REC, cache, object, and voxel structures need
	definition.  Add lines:
		int i, hit ;
		float shadow_percent ;

p. 588, 7th line from bottom:  change "(j+0.5)" to "(dj+0.5)", or delete
		"dj = (double)j;" from previous line (dj currently is not used)
        2nd line from bottom:  change "(k+0.5)" to "(dk+0.5)", or delete
		"dk = (double)k;" from previous line (dk currently is not used)
p. 594, middle:  the "const" declarations before the TSpectra definitions
	create assignment incompatibilities; replace with "static".
p. 596, first line of InitParams:  change "int i, n=0;" to "int i;", since
		"n" is not used.

-----

The following are typographical errors in the comments:

p. 461, line 19:  change "transpose matrix a," to "transpose rotation portion
		of matrix a,"

p. 473, line 28:  change "condititions:" to "conditions:"

p. 576, line 30:  change "hit near face," to "hit far face,"

p. 578, line 21:  change "coefficents" to "coefficients"

p. 584, line 12:  change "nubmer" to "number"
p. 588, line 5:  change "arrary" to "array"
p. 590, line 10:  change "radom" to "random"
p. 595, line 24:  change "quarilateral" to "quadrilateral"

p. 610, line 2:  change "varients" to "variants"

-----

Addenda:

Not include in the gem "Intersecting a Ray with an Elliptical Torus" is the
following code which compensates for the order of the roots being transposed.
It was not included since it would make the gem dependent on the behaviour of
the root solver.  Insert after the call to SolveQuartic (middle of p. 579):

/*	SolveQuartic returns root pairs in reversed order.		*/
	if  ( *nhits > 1 )
	    m = rhits[0]; u = rhits[1]; rhits[0] = u; rhits[1] = m;
	if  ( *nhits > 3 )
	    m = rhits[2]; u = rhits[3]; rhits[2] = u; rhits[3] = m;

Also, note that the torus intersector may not handle degenerate surfaces (e.g.
where the major radius < minor radius, or major radius < 0) as desired.


Xiaolin Wu's code for "Efficient Statistical Computations for Optimal Color
Quantization" is available online in quantizer.c, though not in the book.  The
code originally distributed has been modified slightly, with the global
variable "m2" renamed to "gm2" to avoid confusion with the local "m2" in some
routines.

Code for Greg Ward's "Real Pixels" article is not in the book, but is included
in the RealPixels subdirectory of the online code.

The code provided in the online distribution for Greg Ward's "A Recursive
Implementation of the Perlin Noise Function" (noise3.c) has a variety of
functions available (e.g. fractal noise), more than the code in the text.

Included in the distribution code is c_format, a PostScript typesetting program
for C source code (v0.6) by Dale Schumacher.

There is a tester provided for Alan Paeth and David Schilling's "Of Integers,
Fields, and Bit Counting".