MCPcopy Create free account
hub / github.com/LabSound/LabSound / distanceFromPointToLine

Function distanceFromPointToLine

src/extended/SpatializationNode.cpp:16–27  ·  view source on GitHub ↗

http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html

Source from the content-addressed store, hash-verified

14{
15 // http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html
16 float distanceFromPointToLine(const FloatPoint3D & x0, const FloatPoint3D & x1, const FloatPoint3D & x2, float & t)
17 {
18 FloatPoint3D x2x1 = x2 - x1;
19 FloatPoint3D x1x0 = x1 - x0;
20 float l = magnitude(x2x1);
21 t = dot(-x1x0, x2x1) / (l * l);
22
23 FloatPoint3D x0x1 = x0 - x1;
24 FloatPoint3D x0x2 = x0 - x2;
25 float d = magnitude(cross(x0x1, x0x2)) / magnitude(x2x1);
26 return d;
27 }
28}
29
30void Occluders::setOccluder(int id, float x, float y, float z, float radius)

Callers 1

occlusionMethod · 0.85

Calls 3

magnitudeFunction · 0.85
dotFunction · 0.85
crossFunction · 0.85

Tested by

no test coverage detected