http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html
| 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 | |
| 30 | void Occluders::setOccluder(int id, float x, float y, float z, float radius) |