benilla-re systems structs docs

PointTriangleDistanceSquared

function · unassigned · unreached

Address
0x6dc900 · 1147 bytes, up to 0x6dcd7a
Signature
float __fastcall (const NTempest::C3Vector *point, const NTempest::C3Vector *vertex, const NTempest::C3Vector *edge0, const NTempest::C3Vector *edge1)
Meaning
Returns the squared distance from a point to a triangle given by a vertex and two edge vectors
Confidence
verified, proof two
Finding
cmath/solids#point-to-triangle

Finding: Point to triangle in cmath: boxes, cones and triangles

0x6dc900(e0, e1) returns the squared distance from the point P in ecx to the triangle with vertex B in edx and edge vectors e0, e1 on the stack. With r=B−P it minimises Q=a·s²+2b·s·t+c·t²+2d·s+2e·t+f, which is |r+s·e0+t·e1|², over s,t≥0 with s+t≤1. Here a=e0·e0, b=e0·e1, c=e1·e1, d=r·e0, e=r·e1 and f=r·r. With det=|ac−b²|, S=be−cd and T=bd−ae, the closest point is inside when S,T≥0 and S+T≤det, at s=S/det and t=T/det. The result is |Q|.

The derivation is in the doc.

Callers 1

Callees 0

None by a direct call or jump.

Calls and jumps by a bare address, from tables/calls.tsv.