Elements
Elements copied to clipboard
Distance to Line function
Is your feature request related to a problem? Please describe. I had a way to calculate the distance to a Plane and the distance to a point but not the distance to a Line.
Describe the solution you'd like A snippet of the function I built but it could also be implemented building the plane and use distanteTo(Plane p). This function is only the implementation of the geometrical distance from a point to a line.
private static double distanceTo(Vector3 point, Line line) {
var A = line.Start;
var u = line.Direction();
var AP = point - A;
var APxu = AP.Cross(u);
var modAPxu = APxu.Length();
var modu = u.Length();
return modAPxu / modu;
}
Describe alternatives you've considered The other alternative I evaluated is building the Plane containing the line with a Normal perpendicular to the point and after that calculating the distance.
Additional context In the context I used it was because I was trying to find the floor side that is closer to the corridor side where I'm building rooms.
@andrewheumann is adding this in #308.