# Specify Bounds Vpasolve Two Unknowns

2 views (last 30 days)
John on 17 Sep 2021
Commented: William Rose on 24 Sep 2021
y2 = 18.3956
z2 = 11.0572
y3 = 13.3972
z3 = 20.8909
I wish to find the coordinates of the centre of the circle passing through (y2,z2) and (y3,z3).
Coordinates of the centre of the circle (y,z) should be within the bounds 12.5 and 17.5.
There is an infinity of centre coordinates within the bounds that fullfills the bounds criterion. All the centres lay on the same line.
I have data points that should all lay outside of the circle. I will then exclude all circles that have points in it and extract the circle with the largest radius.
Ideally, I'll get a discrete list of possible centers sampled from vpasolve. From this list I can extract the largest circle of interest that lay inside my data points.
My attempt:
syms y z
Solved=vpasolve((y2-y)^2+(z2-z)^2==(y3-y)^2+(z3-z)^2,[y z],[12.5, 17.5:12.5, 17.5])
However, this gives me no solution within the bounds.
Any help is appreciated!

William Rose on 17 Sep 2021
@John, I would use simple geometry.
You say "Coordinates of the centre of the circle (y,z) should be within the bounds 12.5 and 17.5." I assume that you mean
12.5<=x<=17.5, 12.5<=y<=17.5.
Problem:
Given points P2=(y2,z2) and P3=(x3,z3). Find the largest circle passing through P2 and P3, whose center is in the rectangle with corners P0=(y0,z0) and P1=(y1,z1), where y0<y1 and z0<z1.
The set of circle centers lie on the perpendicular bisector of P2,P3. The biggest circle will be where the perpendicular bisector intersects one of the edges of the bounded region. The perpendicular bisector will intersect the edges of the bounded region at 0, 1, or 2 points. Identify the intersection points, if any. The intersection point that is farthest from the midpoint of P2,P3 is the center of the circle with the largest radius.
Perpendicular bisector: y-ymid=m(z-zmid), where ymid=(y2+y3)/3, zmid=(z2+z3)/2, m=(z2-z3)/(y3-y2).
Edges of the bounded region:
Edge 1: y=y0, z0<=z<=z1.
Edge 2: y=y1, z0<=z<=z1
Edge 3: y0<=y<=y1,z=z0
Edge 4: y0<=y<=y1,z=z1
Check the edges:
Edge 1: y0-ymid=m(zc1-zmid) => zc1=(y0-ymid)/m+zmid. If z0<=zc1<=z1, then C1=(y0,zc1) is a viable answer, so save it.
Edge 2: y1-ymid=m(zc2-zmid) => zc2=(y1-ymid)/m+zmid. If z0<=zc2<=z1, then C2=(y0,zc2) is a viable answer, so save it.
Edge 3: yc3-ymid=m(z0-zmid) => yc3=m(z0-zmid)+ymid. If y0<=yc3<=y1, then C3=(yc3,z0) is a viable answer, so save it.
Edge 4: yc4-ymid=m(z1-zmid) => yc4=m(z1-zmid)+ymid. If y0<=yc4<=y1, then C4=(yc4,z1) is a viable answer, so save it.
If there were 2 viable answers, the answer is the one that is farther from Pmid=(ymid,zmid).
##### 2 CommentsShowHide 1 older comment
William Rose on 24 Sep 2021
@John, well done!

R2021a

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!