Shapes & spaces

Generalized winding number calculator for a triangular surface mesh

Evaluate the signed solid-angle sum of an oriented triangular mesh at spatial query points.

Your numbers

One comma-separated row per line.
One comma-separated row per line.
One comma-separated row per line.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Evaluate the signed solid-angle sum of an oriented triangular mesh at spatial query points. Inspect closure separately from the numerical winding value, especially for open meshes or overlapping surfaces.

THE FORMULAw(p)=(1/(4π)) Σ_f Ω_f(p); Ω=2 atan2(det(u,v,w),||u||||v||||w||+(u·v)||w||+(v·w)||u||+(w·u)||v||).

A worked example

The outward-oriented tetrahedron has winding number1 at(0.1,0.1,0.1) and0 at(2,2,2), up to roundoff. Reversing every face changes the interior value to−1. Removing a face generally gives fractional values instead of a closed-solid indicator.

Good to know

3–100 vertices,1–200 nondegenerate oriented triangles,1–30 queries. Reject on/near-surface queries. Edge pairing checks closure and local orientation only; self-intersections and manifold vertex links are not certified. Open or self-intersecting surfaces can have fractional or multiplicity values; no automatic solid classification.

Solid angles combine into a spatial winding field

An oriented triangle covers a signed portion of the viewing sphere centered at the query. Adding these solid angles and dividing by4π gives the generalized winding number of the whole mesh.

For a consistently outward-oriented embedded closed surface, the usual inside value is1 and outside value0. The generalized definition remains meaningful for an open triangle collection, but its values need not be integers.

An oriented tetrahedron separates winding control pointsOutside: w = 0Inside: w = 1Reverse faces: w → −w
The outward-oriented tetrahedron has winding number1 at(0.1,0.1,0.1) and0 at(2,2,2), up to roundoff. Reversing every face changes the interior value to−1. Removing a face generally gives fractional values instead of a closed-solid indicator.

Compare this with the Solid angle calculator for an oriented triangle from a viewpoint. One triangle solid angle or a planar winding number is not a mesh-wide spatial winding field.

Keep face indices and face orientation separate

Vertex rows supply geometry. Each face row contains three zero-based indices into those rows, so index0 means the first vertex. Reordering a face can reverse its sign even though the same three points remain present.

Use a consistent winding convention when preparing a closed mesh. Adjacent outward faces traverse their shared edge in opposite directions. Duplicate faces can add multiplicity rather than improving the geometric resolution.

The atan2 formula preserves angle signs

The numerator is the scalar triple product of the three viewpoint-to-vertex vectors. The denominator combines their lengths and pairwise dot products. Using atan2 preserves the relevant angle branch better than a one-argument inverse tangent.

The implementation also computes the nearest distance to each triangle. A query on the surface has an ambiguous limiting interpretation, so an unresolved near-surface location is rejected instead of returning a confident inside label.

Check the two tetrahedron queries

The first query has positive coordinates whose sum is less than1, placing it inside the unit coordinate tetrahedron. Its outward solid angles add to4π, giving winding1.

The second query lies far outside and its signed triangle angles cancel. Reversing every face negates both sums. This test checks orientation as well as the factor4π; a result based only on unsigned triangle areas would fail it.

Closure is a diagnostic rather than complete validation

Every edge appearing twice with opposite traversal is necessary for a consistently oriented closed triangle surface. The page reports whether this edge condition holds, making an omitted face visible.

That check does not prove there are no self-intersections or singular vertex neighborhoods. Therefore the output remains a winding field with a closure diagnostic, not a universal watertight-manifold or valid-solid certificate.

Fractional values should not be rounded away

An open patch can subtend, for example, a fraction of the viewing sphere. Its fractional value is geometric information about the patch and query, not necessarily a numerical error.

Nested shells, reversed components and overlapping oriented sheets can also alter integer multiplicities. A threshold of one-half may be useful in a particular reconstruction workflow, but it is not automatically justified for every mesh supplied here.

Use the result with a mesh inspection workflow

Compare winding values at known inside and outside control points before relying on uncertain queries. Inspect face orientation and the nearest-surface distance when a value differs from the expected sign or magnitude.

For production solid modeling, add self-intersection, manifold and repair checks in an appropriate geometry tool. This calculator measures the submitted surface without repairing it or changing the intended topology.

A few questions, answered

Why do I see a negative interior value?

The mesh may be oriented inward. Reversing all triangle orientations negates the winding number.

Can an open mesh be evaluated?

Yes, but its values can be fractional and are not certified inside/outside labels.

What does closed oriented mean here?

Every edge occurs exactly twice with opposite traversal. Self-intersections and vertex manifoldness are not certified.

Can I query a point on a face?

No. Near-surface queries are rejected because their limiting winding interpretation is unresolved.

Find your calculator

Start typing to explore the library.