> (I want to split a triangle into many triangles (but only 2 in one
> time)using one function recursing until the area of a triangle is smaller
> than a value.

A simple algorithm is:

split_if_necessary(triangle) {
   if (area(triangle) > max) {
       subtris = subdivide(triangle);  // produces 4 triangles
       for (i = 0; i < 4; i++) {
           split_if_necessary(subtris[i]);
       }
   } else {
       // triangle is small enough
       output_triangle(triangle); // add to your output
   }
}

Subdivide does a simple midpoint subdivision:

Input:

      2
     / \
    /   \
   /     \
  /       \
 /         \
0-----------1

Find the midpoint of each edge:

      2
     / \
    /   \
   4-----3
  / \    /\
 /   \  /  \
0-----5-----1

The output tris are [0,5,4], [5,1,3], [5,3,4], [4,3,2].  If the input is
oriented correctly each of the subdivided triangles will be as well.

More advanced versions subdivide only the longest edges, but they are much more
complex without alot more benefit.


Doug Gehringer
Sun Microsystems

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to