I'm using version 11 for whatever that's worth. I'm doing an optical simulation with thousands of converging rays (HalfLine
s), since this is in 3D for the most part they don't intersect, but I would like to find the closest point among all of the rays. I'm new to Mathematica so I'm trying to figure out what an efficient and idiomatic way to do this is. The docs have a nice example with two regions like this:
{d, pqrul} = Minimize[EuclideanDistance[p, q], {p ∈ 𝒫, q ∈ 𝒬 // RootReduce
I've thought of trying to adapt that somehow (all pairs of points in the RegionUnion
of the lines?) but that seems grossly inefficient. There's always the MATLAB way. Still, I'd like to learn the idiomatic way because I'd also like to be able to visualize these things without packing them into and stripping them out of matrices.
RegionDistance[]
andRegionNearest[]
? $\endgroup$HalfLines
, or just the least squares solution to the problem, anywhere in space? $\endgroup$HalfLine
s, or wouldInfiniteLine
s work, too? That would simplify the problem a lot. I ask because the "Matlab way", as far as I can see, assumes infinite lines. $\endgroup$