Skip to content
Projects

Triangle

The equations of simgeometry.objects.triangle, declared on the code that implements them and checked by the tests.

Triangle

classsource

Represent a triangular geometry object.

inside
p=v0+u (v2−v0)+v (v1−v0),p∈S  ⟺  u≥0,  v≥0,  u+v≤1p = v_0 + u\,(v_2 - v_0) + v\,(v_1 - v_0), \qquad p \in S \iff u \ge 0,\; v \ge 0,\; u + v \le 1
level set
ϕ(p)=±min⁡edges∣p−a−clip⁡ ⁣((p−a)⋅e∣e∣2,0,1)e∣,e=b−a\phi(p) = \pm \min_\text{edges} \left| p - a - \operatorname{clip}\!\left(\tfrac{(p - a)\cdot e}{|e|^2}, 0, 1\right) e \right|, \qquad e = b - a
Assumes
  • barycentric coordinates u,vu, v with closed edges, inside the half-open bounding box
  • a degenerate triangle contains no point
  • ϕ\phi: the distance to the nearest edge, negative inside; exact
References