home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / GraphicsGems / GemsII / Errata.GraphicsGemsII next >
Text File  |  1995-08-07  |  8KB  |  219 lines

  1. Errata to _Graphics Gems II_, first edition, edited by Jim Arvo
  2. (arvo@graphics.cornell.edu), Academic Press 1991.  Code available online in
  3. princeton.edu:pub/Graphics/GraphicsGems/GemsII.
  4.  
  5. compiled by Eric Haines (erich@eye.com) from author and reader contributions
  6.  
  7. version 1.9
  8. date:  11/29/94
  9.  
  10. -----
  11.  
  12. Errors in the text:
  13.  
  14. p. xxix, middle of page:  change "Rod G. Bogart (72)" to
  15.         "Rod G. Bogart (72, 181)".
  16.  
  17. p. 84, line 1:  change "clockwise" to "counterclockwise".
  18. p. 85, line 1:  change "counterclockwise" to "clockwise".
  19.  
  20. p. 194, line 4:  change "nil <- 0" to "int <- 0".
  21.  
  22. p. 194, figure 3:  change "a2.aF" to "e2.aF" and "a2.bF" to "e2.bF".
  23.  
  24. p. 249, last sentence:  change "less than 0, then" to "less than tnear, then".
  25.  
  26. p. 420, line 10:  "Berstein" should read "Bernstein".
  27.  
  28. -----
  29.  
  30. The following are errors in the code listings (corrected in the online code at
  31. princeton.edu:pub/Graphics/GraphicsGems/GemsII).  Note that many of the code
  32. listings online are different in minor and major ways from the code in the
  33. book (see Addenda, at the end, for new code not in the book).
  34.  
  35.  
  36. Serious errors (ones your compiler cannot or may not catch):
  37.  
  38. p. 456: Delete FLOOR and CEILING macros (they're more like truncations).
  39.     Change ROUND macro to (i.e. add parentheses around "a"):
  40.     #define ROUND(a)    ((a)>0 ? (int)((a)+0.5) : -(int)(0.5-(a)))
  41.     Change SGN macro to (i.e. change positive condition result to "1"):
  42.     #define SGN(a)        (((a)<0) ? -1 : 1)
  43.  
  44. p. 463, line 9:  in V3Combine change last "result->y" to "result->z".
  45. p. 571, line 16:  add missing macros:
  46.     #define Trunc(v)        ((int)floor(v))
  47.  
  48.     /* normalize vector, return in pn */
  49.     #define unity(v,pn)     { double len ; \
  50.             len = sqrt((v).x*(v).x+(v).y*(v).y+(v).z*(v).z) ; \
  51.             (pn)->x=(v).x/len; (pn)->y=(v).y/len; \
  52.             (pn)->z=(v).z/len; }
  53.  
  54. p. 572, line 27:  change "struct epthbuf_el {" to "struct depthbuf_el {"
  55. p. 574, 4th line from bottom:  delete "break;" statement in order to move to
  56.     next pair of edges
  57.  
  58. p. 576, line 28:  change "if ( t < 0.0 )" to "if ( t < tnear )"
  59.  
  60. p. 591, line 7:  change "*fp ==1.0;" to "*fp = 1.0;"
  61.  
  62. p. 599, bottom:  add lines:
  63.         typedef struct {
  64.             double x,y,z,w;
  65.         } Vector4;
  66.  
  67.         Vector4 *V4MulPointByMatrix();
  68. p. 600, line 6:  add lines:
  69.         #include <math.h>
  70.         #include "GraphicsGems.h"
  71.         #include "unmatrix.h"
  72. p. 600, line 22:  change to "Matrix4 pmat, invpmat, tinvpmat;"
  73. p. 600, line 25:  change to "Point3 row[3], pdum3;"
  74. p. 600, line 39:  change "pmat.element[4][3] = 1;" to "pmat.element[3][3] = 1;"
  75. p. 601, line 4:  change:
  76.             psol = *V4MulPointByMatrix(&prhs, &invpmat, &vdum4);
  77.         to:
  78.             Transpose( &invpmat, &tinvpmat );
  79.             V4MulPointByMatrix(&prhs, &tinvpmat, &psol);
  80. p. 602, line 5:  change "&row[2])" to "&row[2], &pdum3)"
  81.  
  82. p. 602, bottom:  add the subroutines:
  83.     /* transpose rotation portion of matrix a, return b */
  84.     Matrix4 *TransposeMatrix4(a, b)
  85.     Matrix4 *a, *b;
  86.     {
  87.     int i, j;
  88.     for (i=0; i<4; i++)
  89.         for (j=0; j<4; j++)
  90.         b->element[i][j] = a->element[j][i];
  91.     return(b);
  92.     }
  93.  
  94.     /* multiply a hom. point by a matrix and return the transformed point */
  95.     Vector4 *V4MulPointByMatrix(pin, m, pout)
  96.     Vector4 *pin, *pout;
  97.     Matrix4 *m;
  98.     {
  99.     pout->x = (pin->x * m->element[0][0]) + (pin->y * m->element[1][0]) +
  100.         (pin->z * m->element[2][0]) + (pin->w * m->element[3][0]);
  101.     pout->y = (pin->x * m->element[0][1]) + (pin->y * m->element[1][1]) +
  102.         (pin->z * m->element[2][1]) + (pin->w * m->element[3][1]);
  103.     pout->z = (pin->x * m->element[0][2]) + (pin->y * m->element[1][2]) +
  104.         (pin->z * m->element[2][2]) + (pin->w * m->element[3][2]);
  105.     pout->w = (pin->x * m->element[0][3]) + (pin->y * m->element[1][3]) +
  106.         (pin->z * m->element[2][3]) + (pin->w * m->element[3][3]);
  107.     return(pout);
  108.     }
  109.  
  110. p. 604, line 7 from bottom:  add code to check for singular matrix (near 0
  111.     determinant).  Add code:
  112.  
  113.     /* Is the submatrix A singular? */
  114.     if ((det_1 == 0.0) || (ABS(det_1 / (pos - neg)) < PRECISION_LIMIT)) {
  115.  
  116.         /* Matrix M has no inverse */
  117.         fprintf (stderr, "affine_matrix4_inverse: singular matrix\n");
  118.         return FALSE;
  119.     }
  120.  
  121. -----
  122.  
  123. Syntax errors (ones your compiler or lint will catch):
  124.  
  125. p. 458-466, throughout:  replace "};" with "}" to make lint happy
  126. p. 464, gcd():  the variable "k" is set but not used - remove it
  127.  
  128. p. 477, line 11 and p. 478, lines 15,18:  change "coord" to "gcoord" and
  129.         "last_coord" to "glast_coord" to avoid same name use for
  130.         global and local variables
  131. p. 477, line 20:  delete ", pos=0", since "pos" is not used in code.
  132. p. 483, v_convert code:  change "alpha" to "alph", since "alpha" is a global
  133.         defined in "types.h"
  134.  
  135. p. 543, 547, 548:  comment out text after "#else" and "#endif" statements
  136.     (some compilers don't like this)
  137.  
  138. p. 550, line 21:  change "int i, num_iterations = 0;" to
  139.         "int num_iterations = 0 ;", as "i" is not used
  140. p. 551, 2nd line from bottom:  delete line "Matrix3 *vm;", as "vm" is not used
  141. p. 559, line 14:  delete "int i;" declaration; "i" not used
  142.  
  143. p. 573, line 15:  delete "static" declaration from shadepoly
  144.  
  145. p. 581 throughout:  code is mostly for illustrative purposes; the RAY_REC,
  146.     LIGHT_REC, TRIANGLE_REC, cache, object, and voxel structures need
  147.     definition.  Add lines:
  148.         int i, hit ;
  149.         float shadow_percent ;
  150.  
  151. p. 588, 7th line from bottom:  change "(j+0.5)" to "(dj+0.5)", or delete
  152.         "dj = (double)j;" from previous line (dj currently is not used)
  153.         2nd line from bottom:  change "(k+0.5)" to "(dk+0.5)", or delete
  154.         "dk = (double)k;" from previous line (dk currently is not used)
  155. p. 594, middle:  the "const" declarations before the TSpectra definitions
  156.     create assignment incompatibilities; replace with "static".
  157. p. 596, first line of InitParams:  change "int i, n=0;" to "int i;", since
  158.         "n" is not used.
  159.  
  160. -----
  161.  
  162. The following are typographical errors in the comments:
  163.  
  164. p. 461, line 19:  change "transpose matrix a," to "transpose rotation portion
  165.         of matrix a,"
  166.  
  167. p. 473, line 28:  change "condititions:" to "conditions:"
  168.  
  169. p. 514, line 2:  change "clockwise" to "counterclockwise"
  170.  
  171. p. 576, line 30:  change "hit near face," to "hit far face,"
  172.  
  173. p. 578, line 21:  change "coefficents" to "coefficients"
  174.  
  175. p. 584, line 12:  change "nubmer" to "number"
  176. p. 588, line 5:  change "arrary" to "array"
  177. p. 590, line 10:  change "radom" to "random"
  178. p. 595, line 24:  change "quarilateral" to "quadrilateral"
  179.  
  180. p. 610, line 2:  change "varients" to "variants"
  181.  
  182. -----
  183.  
  184. Addenda:
  185.  
  186. Not include in the gem "Intersecting a Ray with an Elliptical Torus" is the
  187. following code which compensates for the order of the roots being transposed.
  188. It was not included since it would make the gem dependent on the behaviour of
  189. the root solver.  Insert after the call to SolveQuartic (middle of p. 579):
  190.  
  191. /*    SolveQuartic returns root pairs in reversed order.        */
  192.     if  ( *nhits > 1 )
  193.         m = rhits[0]; u = rhits[1]; rhits[0] = u; rhits[1] = m;
  194.     if  ( *nhits > 3 )
  195.         m = rhits[2]; u = rhits[3]; rhits[2] = u; rhits[3] = m;
  196.  
  197. Also, note that the torus intersector may not handle degenerate surfaces (e.g.
  198. where the major radius < minor radius, or major radius < 0) as desired.
  199.  
  200.  
  201. Xiaolin Wu's code for "Efficient Statistical Computations for Optimal Color
  202. Quantization" is available online in quantizer.c, though not in the book.  The
  203. code originally distributed has been modified slightly, with the global
  204. variable "m2" renamed to "gm2" to avoid confusion with the local "m2" in some
  205. routines.
  206.  
  207. Code for Greg Ward's "Real Pixels" article is not in the book, but is included
  208. in the RealPixels subdirectory of the online code.
  209.  
  210. The code provided in the online distribution for Greg Ward's "A Recursive
  211. Implementation of the Perlin Noise Function" (noise3.c) has a variety of
  212. functions available (e.g. fractal noise), more than the code in the text.
  213.  
  214. Included in the distribution code is c_format, a PostScript typesetting program
  215. for C source code (v0.6) by Dale Schumacher.
  216.  
  217. There is a tester provided for Alan Paeth and David Schilling's "Of Integers,
  218. Fields, and Bit Counting".
  219.