Strip comments and inline ids onto h*

This commit is contained in:
James Gregory 2013-12-30 15:11:04 +11:00
commit 0f5f617adb
362 changed files with 2519 additions and 6694 deletions

View file

@ -10,16 +10,9 @@
<meta name="vspubdate" content="07/01/97" />
<meta name="vscategory" content="Web and Software Development: Game Development,Web and Software Development: Graphics and Multimedia Development" />
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Frames of Reference</title><!-- HEADER -->
<!-- Empty Reference Subhead -->
<!--ISBN=1576101746//-->
<!--TITLE=Michael Abrash's Graphics Programming Black Book Special Edition//-->
<!--AUTHOR=Michael Abrash//-->
<!--PUBLISHER=The Coriolis Group, Inc.//-->
<title>Michael Abrash's Graphics Programming Black Book Special Edition: Frames of Reference</title>
<meta name="chapter" content="61" />
<meta name="pages" content="1138-1141" />
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
</head>
<body>
@ -39,9 +32,8 @@
<p>Why does this matter? It matters because, on average, half the polygons in any scene are facing away from the viewer, and hence shouldn&rsquo;t be drawn. One way to identify such polygons is to see whether they&rsquo;re facing toward or away from the viewer; that is, whether their normals have negative z values (so they&rsquo;re visible) or positive z values (so they should be culled). However, we&rsquo;re talking about screenspace normals here, because the perspective projection can shift a polygon relative to the viewpoint so that although its viewspace normal has a negative z, its screenspace normal has a positive z, and vice-versa, as shown in Figure 61.3. So we need screenspace normals, but those can&rsquo;t readily be generated by transformation from worldspace.</p>
<p><a id="Fig3"><!-- </A><A HREF="javascript:displayWindow('images/61-03.jpg',406,343 )"> --><img src="images/61-03.jpg" /><br />
<!-- </A>
<BR><A HREF="javascript:displayWindow('images/61-03.jpg',406,343)"> --><b>Figure 61.3</b></a>&nbsp;&nbsp;<i>A problem with determining front/back visibility.</i></p>
<p><a id="Fig3"><img src="images/61-03.jpg" /><br />
<b>Figure 61.3</b></a>&nbsp;&nbsp;<i>A problem with determining front/back visibility.</i></p>
<p>The solution is to use the cross product of two of the polygon&rsquo;s edges to generate a normal. The formula for the cross product is:</p>
@ -61,15 +53,14 @@
</tr>
</table>
<p><a id="Fig4"><!-- </A><A HREF="javascript:displayWindow('images/61-04.jpg',407,283 )"> --><img src="images/61-04.jpg" /><br />
<!-- </A>
<BR><A HREF="javascript:displayWindow('images/61-04.jpg',407,283)"> --><b>Figure 61.4</b></a>&nbsp;&nbsp;<i>How the cross product of polygon edge vectors generates a polygon normal.</i></p>
<p><a id="Fig4"><img src="images/61-04.jpg" /><br />
<b>Figure 61.4</b></a>&nbsp;&nbsp;<i>How the cross product of polygon edge vectors generates a polygon normal.</i></p>
<p>Perhaps the most often asked question about cross products is &ldquo;Which way do normals generated by cross products go?&rdquo; In a left-handed coordinate system, curl the fingers of your left hand so the fingers curl through an angle of less than 180 degrees from the first vector in the cross product to the second vector. Your thumb now points in the direction of the normal.</p>
<p>If you take the cross product of two orthogonal (right-angle) unit vectors, the result will be a unit vector that&rsquo;s orthogonal to both of them. This means that if you&rsquo;re generating a new coordinate space&mdash;such as a new viewing frame of reference&mdash;you only need to come up with unit vectors for two of the axes for the new coordinate space, and can then use their cross product to generate the unit vector for the third axis. If you need unit normals, and the two vectors being crossed aren&rsquo;t orthogonal unit vectors, you&rsquo;ll have to normalize the resulting vector; that is, divide each of the vector&rsquo;s components by the length of the vector, to make it a unit long.</p>
<h3><a id="Heading8"></a>Using the Sign of the Dot Product</h3>
<h3 id="Heading8">Using the Sign of the Dot Product</h3>
<p>The dot product is the cosine of the angle between two vectors, scaled by the magnitudes of the vectors. Magnitudes are always positive, so the sign of the cosine determines the sign of the result. The dot product is positive if the angle between the vectors is less than 90 degrees, negative if it&rsquo;s greater than 90 degrees, and zero if the angle is exactly 90 degrees. This means that just the sign of the dot product suffices for tests involving comparisons of angles to 90 degrees, and there are more of those than you&rsquo;d think.</p>
@ -79,9 +70,8 @@
<p>Backface culling with the dot product is just a special case of determining which side of a plane any point (in this case, the viewpoint) is on. The same trick can be applied whenever you want to determine whether a point is in front of or behind a plane, where a plane is described by any point that&rsquo;s on the plane (which I&rsquo;ll call the plane origin), plus a plane normal. One such application is in clipping a line (such as a polygon edge) to a plane. Just do a dot product between the plane normal and the vector from one line endpoint to the plane origin, and repeat for the other line endpoint. If the signs of the dot products are the same, no clipping is needed; if they differ, clipping is needed. And yes, the dot product is also the way to do the actual clipping; but before we can talk about that, we need to understand the use of the dot product for projection.</p>
<p><a id="Fig5"><!-- </A><A HREF="javascript:displayWindow('images/61-05.jpg',410,274 )"> --><img src="images/61-05.jpg" /><br />
<!-- </A>
<BR><A HREF="javascript:displayWindow('images/61-05.jpg',410,274)"> --><b>Figure 61.5</b></a>&nbsp;&nbsp;<i>Backface culling with the dot product.</i></p>
<p><a id="Fig5"><img src="images/61-05.jpg" /><br />
<b>Figure 61.5</b></a>&nbsp;&nbsp;<i>Backface culling with the dot product.</i></p>
<p><br /></p>
@ -100,10 +90,6 @@
<div align="center">
Graphics Programming Black Book &copy; 2001 Michael Abrash
</div><!-- all of the reference materials (books) have the footer and subfoot reveresed -->
<!-- reference_subfoot = footer -->
<!-- reference_footer = subfoot -->
<!-- BEGIN SUB FOOTER -->
<!-- END FOOTER -->
</div>
</body>
</html>