Yet another way of using regions to constrain the vector arguments to NMinimize by using Regions. Instead of using p1∈Vectors[2,Reals], a region can also be used p1∈Rectangle[{-1/2,-1/2},{1/2,1/2}] and NMinimize recognizes that p2 is a vector in 2D
/14/22 09:02:10 In[660]:=
Block[{res,center2={2,2},angle=Pi/8},res=Echo@NMinimize[{Norm[p1-p2],Element[p1,InfiniteLine[AngleVector[angle],-AngleVector[angle]]]},{p1∈Rectangle[{-1/2,-1/2},{1/2,1/2}],p2∈Disk[center2,1]},Method{"NelderMead","InitialPoints"->{Flatten[{RandomPoint[Rectangle[{-1/2,-1/2},{1/2,1/2}]],RandomPoint[Disk[center2,1]]}]}}];Graphics[{{Lighter[Red],Disk[center2]/.res〚2〛},{Green,PointSize[0.03],Point[{p1,p2}/.res〚2〛],{Black,InfiniteLine[AngleVector[angle],-AngleVector[angle]]/.res[[2]],Yellow,Opacity[0.3],Rectangle[-1/2{1,1},1/2{1,1}]}}},Axes->True]]
»
{1.33762,{p1{0.5,0.207107},p2{1.35832,1.23303}}}
/14/22 09:02:10 Out[660]=