I know there must be an elegant solution I’m just not thinking of here:
Given: two points A and B and a line C,
I’m looking to find: the point X on line C, where line AXB has the minimum distance of any possible point on C.
I realize that if line C is co-planar with A and B, then X can be thought of as the tangent point of an ellipse tangent to C and with foci A and B.
If line C is NOT co-planar with A and B, then X can be thought of as the tangent point of an ellipsoid tangent to C and with foci A and B. Not sure if this helps us at all…
I know there must be an elegant algebraic solution here I’m just not seeing… Anyone have any ideas?
In case it helps here is the *.gh file I used to make the illustration… this only illustrates the co-planar case… but maybe helps give a better sense of what I’m after.
For anything more complicated than a line, this problem becomes extremely complex and an analytical solution for a circle was only derived fairly recently! For that, @Joseph_Oster’s method is probably best.
Thanks Joseph @Joseph_Oster but I think this solution goes back to the Greeks. I think I remember reading that Leonardo invented a mechanical device to solve it in the case of a circle It’s a question that ,might have come up when painting a column or a pot and wondering where the reflection of a light source would appear.
Joseph and Ethan,
Thanks for both of your insightful replies…
Joseph, I was also thinking about a brute force approach --yours is very nicely done!
Ethan,
Thanks for referring me to Alhazen’s Problem --I have his Book of Optics on the shelf! And your solution using the line to reflect points A and B is indeed quite elegant! Correct me if I’m wrong, but this solution will only work if the line is co-planar to A and B… if the line is not co-planar, we would first need to figure out which plane to reflect in…? Any other thoughts on the non-co-planar case?
That non-planar solution isn’t as obvious as when they are co-planar but seems to work. However, I see an implementation issue due to an assumption about surface normals from EvalSrf. If the C curve (line) is flipped, the surface normals are reversed and the model fails. There must be a way to code a solution that doesn’t depend on curve direction?
I know. When I first posted it, I thought the image was not adequate, so I adjusted one of the points so it would be more apparent, and the normal flipped on that surface, requiring the need to use an Expression so the rotated plane would again be parallel, so it’s not just curve direction. Maybe EvalSrf isn’t the best choice.
I took a closer look at your planar solution and simplified it to how I thought it was working, using Mirror Curve instead of creating a vertical plane,
BRAVO!!! I was wondering about a weighted average but wasn’t sure how to do it. From what I can tell, your solution works fine on both the planar and non-planar cases. I LOVE a simple solution! Very nice.
Still, i feel like i “cheated”.
Is like, pencil on paper, comparing a guy that finds the tangent of a circle by drawing another circle and finding the intersection, and another guy that measure distance and diameter and calculate the position of the tangent point. The latter is so uncool!
Geometrical solution is always more elegant and let you really understand what is going on.
A mathematical solution is more abstract.
I’m not a genius, i was reading this interesting thread and only at @akilli 's non-planar solution i understood that weighted average could be used
Ha ha! Now that I’ve gone over it again I see how I “inspired” you. Once you look at the unfolding into one plane, it’s obvious that its the weighted average along the line. It also avoids the nastiness that @Joseph_Oster mentioned about curve direction.