Consider two figures: a rectangle with coordinates $(x_{min},y_{min}), (x_{min}+dx,y_{min}+dy)$, and a circle. The latter has a radius $R$ and is located at the center of the coordinate frame. How to find the intersection points between these figures?
My attempt is the following (given in terms of some parameters):
ROffAxisArb[\[Theta]_, ztodet_] = ztodet*Tan[\[Theta]];
rec[xtodet_, ytodet_, dxdet_, dydet_] :=
Rectangle[{xtodet, ytodet}, {xtodet + dxdet, ytodet + dydet}]
circ[\[Theta]_, ztodet_] :=
Circle[{0, 0}, ROffAxisArb[\[Theta], ztodet]]
solEasy[xtodet_, ytodet_, ztodet_, dxdet_, dydet_, \[Theta]_] :=
Solve[{x, y} \[Element]
rec[xtodet, ytodet, dxdet, dydet] && {x, y} \[Element]
circ[\[Theta], ztodet], {x, y}]
(*Longitudinal distance to detector*)
ZtoDet = 8.7;
(*Transverse distance to the beginning of detector - y*)
YtoDet = 2;
(*Transverse distance to the beginning of detector - X*)
XtoDet = -1;
(*Transverse size of the detector - width*)
DxDet = 8;
(*Transverse size of the detector - height*)
DyDet = 2;
solEasy[XtoDet, YtoDet, ZtoDet, DxDet, DyDet, 0.6]
It gives some expression $y = f(x)$ for some domain of $x$, which looks meaningless:
{{y -> ConditionalExpression[
0.000283439 Sqrt[4.40966*10^8 - 1.24475*10^7 x^2],
4.40751 <= x <= 5.60591]}}
In contrast, I would expect either two points $\{x_{1},y_{1}\},\{x_{2},y_{2}\}$, or one point, or zero. For instance, graphically for $\theta = 0.6$ I get
lineStyle1 = {Thick, Blue};
lineStyle2 = {Thick, Blue};
lineStyle3 = {Thick, Darker@Darker@Green, Dashing[0.02]};
line1 = Line[{{XtoDet, YtoDet}, {XtoDet, YtoDet + DyDet}}];
line2 = Line[{{XtoDet + DxDet, YtoDet}, {XtoDet + DxDet,
YtoDet + DyDet}}];
Plot[{f[x, ROffAxisArb[0.6, ZtoDet]],
If[XtoDet < x < XtoDet + DxDet, YtoDet, -10],
If[XtoDet < x < XtoDet + DxDet,
YtoDet + DyDet, -10]}, {x, -1.2 (Abs[XtoDet] + Abs[DxDet]),
1.2 (Abs[XtoDet] + DxDet)},
PlotRange -> {{-1.2 (Abs[XtoDet] + DxDet),
1.2 (Abs[XtoDet] + DxDet)}, {0, 1.2 (YtoDet + DyDet)}},
Frame -> True, FrameStyle -> Directive[Black, 25], PlotRange -> All,
PlotStyle -> {{Thick, Red}, {Thick, Blue}, {Thick, Blue}},
ImageSize -> Large,
FrameLabel -> {"x",
"y"},(*PlotLegends\[Rule]Placed[Style[#,24]&/@{"Subscript[\[Theta],\
min]","Subscript[\[Theta], max]","Subscript[\[Theta], \
max,1]","Subscript[\[Theta], max,2]"},Right],*)AspectRatio -> 1,
Epilog -> {Directive[lineStyle1], line1, Directive[lineStyle2],
line2}]
Could you please tell me how to get just two points (or one point, or nothing) as a solution?