Builtin Library
- ..
- README.md3.0 KB
- module.wgsl15.1 KB
README.md
intersect_core
The triangle pair tests of the intersect kernels. A pair of triangles, a of mesh A and b of mesh B,
has a cut in parts; every part is a segment, and an endpoint is named by the edges or the corner it is made
of, and computed from nothing else, so the triangles that share an edge compute the same point to the bit.
The includer binds apts, atri, bpts and btri. zi_part(a, b, part) answers part part as a ZiCut
(ok when the part is present, and its endpoints e0 and e1). intersect_pairs and intersect_cuts include it.
Parts
| Part | What | Cuts |
|---|---|---|
| 0 | The ordinary cut of two triangles that are not coplanar: the segment with two endpoints, each an edge of one triangle crossing the other (zi_pair). A vertex exactly on a plane counts as on its positive side, so triangles that only touch cross consistently or not at all. | A and B |
| 1 to 3 | Coplanar triangles: edge part - 1 of b, clipped to the closed triangle a. | A |
| 4 to 6 | Coplanar triangles: edge part - 4 of a, clipped to the closed triangle b. | B |
| 7 to 15 | Edge i of a and edge j of b lie in one plane and cross strictly inside both: the crossing, part 7 + 3 i + j. A segment of no length. | A and B |
| 16 to 24 | Corner v of a lies exactly strictly inside edge j of b: part 16 + 3 v + j. A segment of no length. | A and B |
| 25 to 33 | Corner v of b lies exactly strictly inside edge i of a: part 25 + 3 v + i. A segment of no length. | A and B |
Triangles are coplanar when neither is degenerate and every corner of each is exactly on the plane of the other (the signed volume is 0). Coplanar triangles have parts 1 to 6 and no part 0; a part is present when the clipped edge keeps a length. The clip is made in the projection along the axis the plane's normal points along most, with every edge taken from its lower point id to its higher; an edge is cut where it leaves the triangle by the line of an edge of the triangle.
Parts 7 to 33 split an edge: a cut point that lies on an edge is a point of every triangle that uses the edge, whatever plane that triangle lies in, so every pair of a triangle of A and a triangle of B that share the edges reaches it and reports the same point. A crossing is computed along the edge of A from the two edges alone.
Endpoint records
An endpoint is ZiEnd: its position, the kind word (the kind in the low byte, which meshes the segment
cuts in bits 8 and 9, 1 mesh A, 2 mesh B, 3 both), lo, hi, tri and extra.
| Kind | Endpoint | lo, hi | tri, extra |
|---|---|---|---|
| 0 | an edge of A through triangle tri of B | the edge | tri, 0 |
| 1 | an edge of B through triangle tri of A | the edge | tri, 0 |
| 3 | an edge of B crossing an edge of A in their plane | the edge of A | the edge of B |
| 4 | a point of B | its id, twice | 0, 0 |
| 5 | a point of A | its id, twice | 0, 0 |
Two endpoints with all of kind word, lo, hi, tri and extra equal are one point.