Skip to content

Commit

Permalink
initial checkins, minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
erich666 committed Apr 9, 2016
1 parent e354b73 commit e32edad
Show file tree
Hide file tree
Showing 48 changed files with 69,543 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ The following articles have related code; look in the corresponding folder by Vo

* Steed, Anthony, ["Pseudo-Shadowed Cursors for 3D Interaction,"](http://www.tandfonline.com/doi/abs/10.1080/10867651.2002.10487562) *journal of graphics tools*, 7(3):19-25, 2002. [**Code**](Volume_07/Number_3/Steed2002)

* Low, Kok-Lim, and Adrian Ilie, ["Computing a View Frustum to Maximize an Object's Image Area,"](http://www.tandfonline.com/doi/abs/10.1080/10867651.2003.10487578) *journal of graphics tools*, 8(1):3-15, 2003. [**Code**](Volume_08/Number_1/Low2003)

* Shen, Hao, Pheng Ann Heng, and Zesheng Tang, ["A Fast Triangle-Triangle Overlap Test Using Signed Distances,"](http://www.tandfonline.com/doi/abs/10.1080/10867651.2003.10487579) *journal of graphics tools*, 8(1):17-24, 2003. [**Code**](Volume_08/Number_1/Shen2003)

* Guigue, Philippe, and Olivier Devillers, ["Fast and Robust Triangle-Triangle Overlap Test Using Orientation Predicates,"](http://www.tandfonline.com/doi/abs/10.1080/10867651.2003.10487580) *journal of graphics tools*, 8(1):25-32, 2003. [**Code**](Volume_08/Number_1/Guigue2003)

* Lewiner, Thomas, Hélio Lopes, Antônio Wilson Vieira, and Geovan Tavares, ["Efficient Implementation of Marching Cubes' Cases with Topological Guarantees,"](http://www.tandfonline.com/doi/abs/10.1080/10867651.2003.10487582) *journal of graphics tools*, 8(2):1-15, 2003. [**Code, partial tables**](Volume_08/Number_2/Lewiner2003)
Expand Down
15 changes: 15 additions & 0 deletions Volume_07/Number_2/Sunday2002/errata.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Errata

The following errors were introduced during the typesetting process:

Page 11, section 3, sentence 1: The reference to [O�Rourke98] is spurious; the sentence should only cite [Goldman94].

Page 11, section 3, sentence 3: The sentence starting with "We improve this..." should read:

"We improve this by using the fact that projecting the polygon to two dimensions reduces its area by a constant factor; for example, projection onto the xy-plane reduces the area by nz."
Page 12, top line: The two numbers "1 sqrt(3)" are incorrect; the first should be "1/sqrt(3)" and the second "sqrt(3)". Thus the sentence should read:

"...for this is 1 / sqrt(3), the largest factor by which one multiplies is sqrt(3); hence ..."
Page 12, third paragraph, first sentence: The sentence starting with "We call this normal vector..." should read:

We call this normal vector, nw = (nwx, nwy, nwz), with the projected areas ...
2 changes: 1 addition & 1 deletion Volume_07/Number_3/Steed2002/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ A pre-compiled Windows executable is available in the following archive: pseudo_

Follow-up

Since the original paper was written for JGT, Everitt and Kilgard published their paper Practical and Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering. Their z-fail approach was adopted in the above example program as it simplified the code which otherwise had to deal with capping the shadow volumes on the near clipping plane since the infinite slab would often intersect the view plane window. To use the z-fail approach the infinite slabs are now large enough that they extend beyond the scene, but are not clipped by the far clipping plane.
Since the original paper was written for JGT, Everitt and Kilgard published their paper "Practical and Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering". Their z-fail approach was adopted in the above example program as it simplified the code which otherwise had to deal with capping the shadow volumes on the near clipping plane since the infinite slab would often intersect the view plane window. To use the z-fail approach the "infinite slabs" are now large enough that they extend beyond the scene, but are not clipped by the far clipping plane.
225 changes: 225 additions & 0 deletions Volume_08/Number_1/Guigue2003/addendum.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
<html>
<head>
<title>
Fast Ray-Triangle Intersection Test using Orientation Determinants</title>
</head>
<body bgcolor="#ffffff">

<h1>
<center>Fast Ray-Triangle Intersection Test Using Orientation Determinants</center></h1>
<center>Philippe Guigue, Olivier Devillers</center><br>
<center>
<i>
Addendum to
<a href="readme.txt">Fast and robust triangle-triangle overlap test using orientation predicates.</a> jgt 8(1), 2003
</i>
</center>
<hr>
<!-- Created: Sat May 28 15:08:50 MET 2005 -->
<h3>Abstract:</h3>
<p>
We describe in the following how the value of orientation determinants
can be used to obtain an efficient solution for the ray/triangle intersection problem.
<p>
This problem can be stated as follow: given a triangle <b>abc</b>, and a
ray <b>r</b>(<em>t</em>) = <b>o</b> + <em>t</em><b>dir</b> defined by its
origin point <b>o</b>, and a direction vector <b>dir</b>, decide whether
the ray and the triangle intersect, and if so, compute the barycentric
coordinates (<em>u</em>,<em>v</em>) of the intersection point,
<b>r</b>(<em>t</em>) = (1 - <em>u</em> - v)<b>a</b> + <em>u</em><b>b</b>+ <em>v</em><b>c</b>.
<p>
The structure of the algorithm is identical to the algorithm
presented by Möller and Trumbore (<a href="../../../Volume_02/Number_2/Moller1997b/">Fast, Minimum
Storage Ray-Triangle Intersection</a>, Journal of graphics tools, 2(1):21--28, 1997),
i.e. it performs in the same order the same rejection
tests on the barycentric coordinates of the intersection point between the ray and
the supporting plane of the triangle.
The algorithms differ only in the way these barycentric coordinates are calculated.

<h3>Source Code:</h3><a href="tri_tri_intersect.c">Downloadable
C code</a> contains the routine:<br><br>
<table>
<tbody>
<td nowrap="nowrap" valign="top"><dd><tt>int ray_triangle_intersection(</td>
<td><tt> double orig[3], double dir[3],
<br>
<tt>double a[3], double b[3], double c[3],<br>
double *t, double *u, double *v)</pre></tt>
</center>
</tbody>
</table>
<br>
The routine returns 1 if the ray defined by its
origin point <tt>orig</tt> and a direction vector <tt>dir</tt>
intersects the triangle having vertices <tt>a</tt>, <tt>b</tt> and
<tt>c</tt>.
If an intersection exists, the triplet <tt>(t,u,v)</tt>, such that
<nobr><tt>orig + t*dir = (1-u-v)*a + u*b + v*c</tt></nobr>
is returned. The code includes two versions of the intersection test: one that culls efficiently all backfacing triangles, and one that performs the test on two-sided triangles.
<br><br><b><em>Revision history:</em></b>
<dl>
<dd>
<table>
<tbody>
<tr>
</tr><tr>
<td nowrap="nowrap" valign="top"><em>May 2005</em></td>
<td>Program creation.</td>
</tr>
</tbody></table></dd></dl><br>

<h3><b>Preliminaries:</b></h3>
Given four three-dimensional points
<nobr><b>a</b><i>=(a_x,a_y,a_z)</i></nobr>,
<nobr><b>b</b><i>=(b_x,b_y,b_z)</i></nobr>,
<nobr><b>c</b><i>=(c_x,c_y,c_z)</i></nobr>, and
<nobr><b>p</b><i>=(p_x,p_y,p_z)</i></nobr>, we define the determinant
<br>
<br>

<center>
<table>
<tbody>
<tr>
<td nowrap="nowrap" valign="center">[<b>a,b,c,p</b>] := - </td>
<td nowrap="nowrap" valign="center"> </td>
<td><table>
<tr><td>|</td><td><i>a_x</i></td><td><i>b_x</i></td><td><i>c_x</i></td><td><i>p_x</i></td><td>|</td></tr>
<tr><td>|</td><td><i>a_y</i></td><td><i>b_y</i></td><td><i>c_y</i></td><td><i>p_y</i></td><td>|</td></tr>
<tr><td>|</td><td><i>a_z</i></td><td><i>b_z</i></td><td><i>c_z</i></td><td><i>p_z</i></td><td>|</td></tr>
<tr><td>|</td><td>1</td><td>1</td><td>1</td><td>1</td><td>|</td></tr>
</table></td>
<td nowrap="nowrap" valign="center">= (<b>p</b> - <b>a</b>).((<b>b</b>-<b>a</b>) x (<b>c</b> - <b>a</b>))</td>
</tr>
</tbody></table>
<br>
</center>
The sign of [<b>a</b>,<b>b</b>,<b>c</b>,<b>d</b>] has two geometric interpretations, each correponding to a right-hand rule. It tells whether vertex <b>d</b> is above, below, or on a plane through <b>a</b>, <b>b</b>, and <b>c</b>, where <em>above</em> is the direction of a right-handed screw at a that turns from <b>b</b> toward <b>c</b>.
Equivalently, it tells whether a screw directed along the ray <b>ab</b> turns in the direction of <b>cd</b>.
In either interpretation, the result is zero iff the four points are coplanar.
<p>
The value of [<b>a</b>,<b>b</b>,<b>c</b>,<b>d</b>] gives 6 times the signed volume of the tetrahedron <b>abcd</b>. <br>
<p>
Given a triangle <b>abc</b> and a point <b>p</b> that belongs to the plane of <b>abc</b>,
the barycentric coordinates of <b>p</b>
are the three scalar values (<em>u,v,w</em>) such that
<br>
<br>
<center>
<b>p</b>=<em>w</em><b>a</b> + <em>u</em><b>b</b> + <em>v</em><b>c</b>.</center>
<br>
It is well known that the signed areas of the triangles <b>abp</b>, <b>acp</b> , and <b>bcp</b> are proportional to the barycentric coordinates <em>v</em>, <em>u</em>, and <em>w</em> of <b>p</b> (cf. Mathworld, <a href="http://mathworld.wolfram.com/BarycentricCoordinates.html">Barycentric Coordinates</a>).
The proportionality factor for all three values is then given by the area of the triangle <b>abc</b>.
If A(<b>abc</b>) denotes the signed area of the triangle <b>abc</b>, we then have<br><br>
<center><em>u</em> = A(<b>cap</b>) / A(<b>abc</b>)</center><br>
<center><em>v</em> = A(<b>abp</b>) / A(<b>abc</b>)</center><br>
<center><em>w</em> = A(<b>bcp</b>) / A(<b>abc</b>)</center><br>
<br>
Moreover, if <b>p</b> belongs to the triangle <b>abc</b>, its barycentric coordinates must fulfill
<em>u</em>&ge;0, <em>v</em>&ge;0, <em>w</em>&ge;0 and <em>u</em>+<em>v</em>+<em>w</em>=1, which is equivalent
to <em>u</em>&ge; 0, <em>v</em>&ge;0 and <em>u</em>+<em>v</em>&le;1.
<br>
<br>

<br>
<br>
<h3><b>Description of the Algorithm:</b></h3>

Given a triangle <b>abc</b>, and a ray <b>r</b>(<em>t</em>) = <b>o</b> +
<em>t</em><b>dir</b>, defined by its origin point <b>o</b> and a direction vector <b>dir</b>,
let <b>i</b> be the intersection point between the ray and the triangle's supporting plane.
The cases where the ray direction is coplanar with the plane of <b>abc</b>
is not handled by the algorithm. It can however be easily detected (see Step 1 of the algorithm) and handled by a specialized two-dimensional routine.<br>
<br>

Let <b>q</b> be any point on the ray. The volume
of the three tetrahedra <b>oqab</b>, <b>oqac</b>, and
<b>oqbc</b> are proportional to the areas of the triangles <b>abi</b>,
<b>aci</b>, and <b>bci</b>, and therefore give the unnormalized
barycentric coordinates of <b>i</b> (cf. Ray Jones, <a href="http://raytracingnews.org/rtnv13n1.html">Intersecting a Ray and a Triangle with Plucker Coordinates</a>, Ray Tracing News, 13(1), July 2000 ).
<br>
More precisely, if V(<b>abcd</b>) denotes the signed volume of the tetrahedron <b>abcd</b>, we have <br><br>
<center>V(<b>oqac</b>) = 1 / 3 . A(<b>cai</b>) . (h<b>o</b> - h<b>q</b>)</center><br>
<center>V(<b>oqab</b>) = - 1 / 3 . A(<b>abi</b>) . (h<b>o</b> - h<b>q</b>)</center><br>
where h<b>p</b> denotes the signed distance from <b>p</b> to the plane of <b>abc</b>.<br><br>


Hence, since the value of the determinant [<b>abcd</b>] gives 6 times the signed volume of the tetrahedron <b>abcd</b>,
the barycentric coordinates <em>u</em> and <em>v</em> of the point <b>i</b> are respectively equal to<br><br>

<center><em>u</em> = [<b>o,q,a,c</b>] / ( 2 . (h<b>o</b> - h<b>q</b>) . A(<b>abc</b>))</center>
and
<center><em>v</em> = -[<b>o,q,a,b</b>] / ( 2 . (h<b>o</b> - h<b>q</b>) . A(<b>abc</b>)).</center>
<br>
<br>
With, <b>q</b> = <b>o</b> + <b>dir</b>, and 2 . (h<b>o</b> - h<b>q</b>) . A(<b>abc</b>) = 6 ( V(<b>abco</b>) - V(<b>abcq</b>) ) =
[<b>a,b,c,o</b>] - [<b>a,b,c,q</b>] = - [<b>a,b,c,dir</b>], we finally obtain
<br>
<br>
<center><em>u</em>= [<b>o,q,a,c</b>] / - [<b>a,b,c,dir</b>]</center>
and
<center><em>v</em>= -[<b>o,q,a,b</b>] / - [<b>a,b,c,dir</b>].</center>
<br>
<br>
The value ray parameter <em>t</em> such that <b>r</b>(<em>t</em>) =
<b>i</b> is also proportional to the volume of the tetrahedron <b>abco</b>
with the same proportionality factor, that is <nobr><em>t</em> =
V(<b>abco</b) / ( V(><b>abco</b>) - V(<b>abcq</b>) ) = [<b>a,b,c,o</b>] / -
[<b>a,b,c,dir</b>]</b>.</nobr>


<br>
<br>
<br>
The step of the algorithm are as follows:


<br>
<br>
<b>Step 1:</b> &nbsp; Compute the normalizing factor D =&nbsp;-<b>dir</b> . N, where
N = (<b>c</b> - <b>a</b>) x (<b>b</b> - <b>a</b>), is the non-normalized normal of the triangle <b>abc</b>.
If its value is zero, the ray is parallel to the plane of the triangle.
If its value is positive, the ray's origin sees the front face of the triangle, if it is negative
the ray's origin sees its back face.
We assume wlog in the following that D &gt; 0 (the case where D &lt; 0 is handled similarly but with opposite signs,
the case where <nobr>D = 0</nobr> is rejected by the current implementation of the algorithm).
<br>
<br>
<b>Step 2:</b> &nbsp; Compute the non-normalized V coordinate and test bounds.
To do so, the algorithm computes the determinant V = -[<b>o,o + dir,a,b</b>].
If V &lt; 0 or V &gt; D, the ray misses the triangle.
<br>
<br>
<b>Step 3:</b> &nbsp; Compute the non-normalized U coordinate and test bounds.
This is done by computing the determinant U = [<b>o,o + dir,a,c</b>].
If U &lt; 0 or U + V &gt; D, the ray misses the triangle.
<br>
<br>
<b>Step 4:</b> &nbsp; Return the normalized values.
In this last step, the algorithm computes the determinant T = [<b>a,b,c,o</b>].
If T / D &ge; 0, the algorithm then returns the triplet ( U / D, V / D, T / D),
otherwise, the ray misses the triangle.
<br>
<br>


<h3><b>Implementation:</b></h3>

The computation of the two first determinants [<b>o,o + dir,a,b</b>] and [<b>o,o + dir,a,c</b>]
can be optimized by computing the invariant parts consisting of 2 x 2 subdeterminants only once.
<p>
For [<b>o, o + dir,a,X</b>], expansion by 2 x 2 determinants gives the vector
<b>dir</b> x (<b>a</b> - <b>o</b>), and reduces the two determinants to a cross-product and
a dot product. <br>
Since [<b>a,b,c,o</b>] = <b>o</b> . N, the computation of the last determinant reduces
to a dot product.<br>
The whole intersection algorithm thus computes, as in [jgt97], two cross-product and four dot products
in the worst case (i.e. when the ray intersect the triangle).
<p>
Nevertheless, our implementation yields to an optimized version of the algorithm described in [jgt97]
in the case when the triangle normal is known.
Indeed, a cross-product can be saved if the normal is supplied.
This normal must however be non normalized, that is, it must equal the cross-product
of (<b>c</b> - <b>a</b>) and (<b>b</b> - <b>a</b>).
</body>
</html>
57 changes: 57 additions & 0 deletions Volume_08/Number_1/Guigue2003/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
From https://web.archive.org/web/20120118225810/http://jgt.akpeters.com/papers/GuigueDevillers03/

Fast and Robust Triangle-Triangle Overlap Test using Orientation Predicates

Philippe Guigue and Olivier Devillers
INRIA Sophia-Antipolis

This paper appears in issue Volume 8, Number 1.
Purchase this issue from the akpeters.com web site.


Abstract

This paper presents an algorithm for determining whether two triangles in three dimensions intersect. The general scheme is identical to the one proposed by M�ller. The main difference is that our algorithm relies exclusively on the sign of 4 x 4 determinants and does not need any intermediate explicit constructions which are source of numerical errors. Besides the fact that the resulting code is more reliable than existing methods, it is also more efficient. The source code is available online.

Author Information

Philippe Guigue, INRIA Sophia-Antipolis, BP 93, 2004 Route des Lucioles06902 Sophia-Antipolis Cedex, France [email protected]

Olivier Devillers, INRIA Sophia-Antipolis, BP 93, 2004 Route des Lucioles06902 Sophia-Antipolis Cedex, France [email protected]


Editor�s Note

This is one of two simultaneous triangle-triangle overlap papers in this issue; see also Shen, Heng and Tang 03. This paper has also been chosen for inclusion in the book Graphics Tools�The JGT Editors� Choice; see addendum below.


Source Code

Downloadable C source code is available here: triangle_triangle_intersection.c (19K HTML text). It contains three routines:

tri_tri_overlap_test_3d(), the three-dimensional predicate described in the paper

tri_tri_overlap_test_2d(), the two-dimensional predicate

tri_tri_intersection_test_3d(), the version that computes the line segment of intersection if the triangles do overlap and are not coplanar.


Revision history

July 2002
Program creation.
October 2002
Added optimizations.
January 2003
Added version that computes the line of intersection.
June 2003
Bug fix. Thanks to Tushar Udeshi for pointing it out!
December 2003
Bug fix.
Addendum


A Ray-Triangle Intersection Test

As part of the inclusion of this paper in the book Graphics Tools�The JGT Editors� Choice, the authors discuss how the value of determinants introduced in the paper can be used to obtain an efficient solution for the ray-triangle intersection problem, and provide source code. See: Fast Ray-Triangle Intersection Test Using Orientation Determinants

25 changes: 25 additions & 0 deletions Volume_08/Number_1/Low2003/_readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Computing a View Frustum to Maximize an Object�s Image Area

Kok-Lim Low and Adrian Ilie
University of North Carolina at Chapel Hill

This paper appears in issue Volume 8, Number 1.
Purchase this issue from the akpeters.com web site.


Abstract

This paper presents a method to compute a view frustum for a 3D object viewed from a given viewpoint, such that the object is completely enclosed in the frustum and the object�s image area is also near-maximal in the given 2D rectangular viewing region. This optimization can be used to improve the resolution of shadow maps and texture maps for projective texture mapping. Instead of doing the optimization in 3D space to find a good view frustum, our method uses a 2D approach. The basic idea of our approach is as follows. First, from the given viewpoint, a conveniently-computed view frustum is used to project the 3D vertices of the object to their corresponding 2D image points. A tight 2D bounding quadrilateral is then computed to enclose these 2D image points. Next, considering the projective warp between the bounding quadrilateral and the rectangular viewing region, our method applies a technique of camera calibration to compute a new view frustum that generates an image that covers the viewing region as much as possible.


Author Information

Kok-Lim Low, Dept of Computer Science, UNC Chapel Hill, CB #3175, Sitterson Hall, Chapel Hill, NC 27599-3175 [email protected]

Adrian Ilie, Dept of Computer Science, UNC Chapel Hill, CB #3175, Sitterson Hall, Chapel Hill, NC 27599-3175 [email protected]


Source Code

Downloadable C/C++ source code is available here: lowk_jgt_src.zip (63K zip archive). Several files from Numerical Recipes in C (http://numerical.recipes/) are needed as well, see the readme.txt file for details.

Binary file added Volume_08/Number_1/Low2003/checker_gray.rgb
Binary file not shown.
Loading

0 comments on commit e32edad

Please sign in to comment.