Measures how far a point is from a plane, with a sign: positive on the side the normal points to, negative on the other.
Example: point [0,5,0] and the XZ plane with normal [0,1,0] -> 5
The point and the plane
The signed distance in model units
Turns a list of triangles into an indexed mesh, which stores each point once.
Corners that agree within tolerance in every coordinate become one point, kept where it first
appears, so triangles that meet share their corners and the mesh knows its neighbours.
Example: two triangles that share an edge -> 4 points and 6 indices
The triangles and the tolerance
The indexed mesh
Turns an indexed mesh back into a list of triangles, each written out as its three points.
Normals the mesh carries are left out, since a triangle list has no place for them. Example: 4 points and indices [0, 1, 2, 1, 3, 2] -> 2 triangles
The indexed mesh
The triangles
Gives an indexed mesh smooth normals, one per point, so it shades without visible facets.
Each point's normal sums those of the triangles around it, a large triangle counting for more than a sliver. The points and triangles stay as they are. Example: a welded cube -> 2 corner normals on diagonals, 6 tipped 19.47 degrees
The indexed mesh
The mesh with normals filled in
Gives an indexed mesh normals that keep its sharp edges sharp and smooth the rest.
Where triangles turn from each other by more than angle, the point between them is split,
one copy per side, so a cube keeps hard edges while a cylinder's side shades smoothly.
Example: a welded cube, angle 30 -> 24 points, 4 per face
The indexed mesh and the angle of its sharp edges
The mesh with its points split at sharp edges and normals filled in
Splits an indexed mesh into its connected pieces and finds the triangles that wind against the first triangle of their piece.
Triangles that share an edge belong to one piece; an edge more than two share is not followed. Example: two separate triangles -> count 2, nothing to turn over
The indexed mesh
Per triangle, whether to turn it over and its piece, and the number of pieces
Turns over the triangles of an indexed mesh that wind against the rest of their piece.
Each connected piece keeps the winding most of its area has, so a few triangles written inside out are mended and a piece wound inward on purpose stays. Example: a cube with one face inside out -> every face outward
The indexed mesh
The mesh with those triangles turned over; normals are left out
Measures the volume a closed triangle mesh encloses, with a sign: positive when its triangles face outwards by the right-hand rule, negative when they all face inwards.
A mesh that is not closed has no inside, and the number it gives means nothing. Example: a unit cube facing outwards -> 1
The enclosed volume in cubic model units
Tells whether two triangle meshes come within a distance of each other, touching and crossing included, as a quick collision test.
It stops at the first triangles close enough; a mesh, or any separate piece of one, wholly inside a closed one counts too. Example: two unit cubes half a unit apart, distance 0.6 -> true; distance 0.4 -> false
The two meshes and the distance
True when the meshes come within the distance
Tells whether a point lies inside a closed triangle mesh.
Rays from the point in three directions count the triangles they cross; an odd count for most of them means inside. A mesh that is not closed has no inside, and the answer means nothing. Example: [0.5, 0.5, 0.5] in a unit cube -> true
The closed mesh and the point
True when the point is inside the mesh
Finds every segment where the surfaces of two meshes cut through each other, testing each triangle of one against each triangle of the other.
Example: a cube mesh and a sphere mesh -> the segments that together trace their intersection curve
The two meshes and the tolerance
The crossing segments, in no particular order
Finds where the surfaces of two meshes cut through each other and joins the pieces into polylines, closed where the curve loops.
Example: a cube mesh and a sphere mesh -> closed polylines where the two surfaces meet
The two meshes and the tolerance
The intersection curves as polylines
Finds where the surfaces of two meshes cut through each other, as one list of points per curve.
A closed curve repeats its first point at the end so the loop is explicit. Example: a cube mesh and a sphere mesh -> point lists tracing where the two surfaces meet
The two meshes and the tolerance
One point list per intersection curve
Cuts a flat polygon, with any holes through it, into triangles.
Every corner stays a corner of a triangle, so neighbouring polygons give a mesh closed along the edges they share. The triangles face the way the outline turns, by the right-hand rule; holes may run either way. Example: a 4 by 4 square -> two triangles
The outline and its holes
The triangles, each three points
Makes a sphere as an evenly triangulated mesh, the icosahedron split detail times.
Its triangles are close to equal in size everywhere, unlike a sphere made of latitude and longitude bands, and each faces outward. Each level of detail has four times the triangles. Example: detail 0 -> 20 triangles, detail 2 -> 320
The center, the radius and the detail
The sphere's triangles
Makes a cone, a cylinder or a cone with its tip cut off, as a closed triangulated mesh.
It stands on center and rises along direction by height, with flat ends and sides
flat faces around. Equal radii make a cylinder.
Example: top radius 0, height 2 -> a cone 2 units tall
The bottom center, the direction, the radii, the height and the sides
The shape's triangles
Finds the plane a triangle lies in: its unit normal and its distance from the origin along that normal.
The normal follows the right-hand rule around the triangle's points. A triangle with no area, whose points are on one line, has no plane and gives undefined. Example: [[0,0,0], [1,0,0], [0,1,0]] -> { normal: [0,0,1], d: 0 }
The triangle and the tolerance below which its area counts as zero
The plane, or undefined for a flat triangle
Finds the segment where two triangles cut through each other.
Triangles that do not touch, are parallel, or lie in the same plane give undefined. Example: a triangle in the XY plane and one standing across it -> the segment where they cross
The two triangles and the tolerance
The crossing segment, or undefined when there is none
Geometry on plain triangle meshes: a mesh is a list of triangles, each three points. The methods here work out the plane of a triangle, the distance from a point to a plane, and where two meshes cut through each other, as segments, as polylines or as point lists, measure the volume a closed mesh holds, and build simple meshes (an icosphere, a frustum). Indexed meshes, which store each point once, convert to and from triangle lists and take smooth or creased normals and consistent winding. They need no CAD kernel, so they run on any triangulated data.