Em 12/06/18 08:31, Едуард Зозуля escreveu:
>
> For my task, everything can be simplified by imposing auxiliary restrictions:
> 1) The radii (half of the axis) of the ellipse are placed strictly on the axis-x and axis-y
> 2) Instead of a intersect with a rectangle, we find points intersect with a circle
> 3) The circle center always lies (placed) on the line of the ellipse
>
> Example picture:
>
http://doro.poltava.ua/vintersect.png
>
> I understand that it is necessary to solve the system of equations:
> (x-x0)**2 + (y-y0)**2 = r**2
> x**2/a**2 + y**2/b**2 = 1
> but, this is a difficult
>
If the circles are "small", i.e. r**2 / (a**2 + b**2) << 1, and your
lines are thick - as you example image suggests - maybe you can do with
an approximate solution.
Lets assume y>0.
Then the half-ellipse can be expressed as
y = b * sqrt(1 - x**2/a**2)
We can approximate the ellipse, near some point over it, (x0,y0), with a
line with slope, m, equal to the derivative at that point:
dy/dx = -b*x/(a*sqrt(a**2-x**2))
replacing x=x0
m = -b*x0/(a*sqrt(a**2-x0**2))
The line is
(y-y0) = m*(x-x0)
replacing this on the circle equation (y-y0)**2 + (x-x0)**2 = r**2 we
get the values for the x coordinate of the intercept points, xi:
xi = x0 +/- r/sqrt(1+m**2)
replace these back in the ellipse equation to get the respective yi
coordinates.
In short, given: a, b, r, x0 (y0 is defined from x0 because we assumed
y>0 and the point is over the ellipse) compute:
m = -b*x0/(a*sqrt(a**2-x0**2))
xip = x0 + r/sqrt(1+m**2)
xim = x0 - r/sqrt(1+m**2)
yip = b * sqrt(1 - xip**2/a**2)
yim = b * sqrt(1 - xim**2/a**2)
(notation: i for intercept, m and p for minus and plus)
The intercepts are (near to) (xip,yip) and (xip,yip)
If y<0, then use -y, and at the end use -yip and -yim (i.e, flip the y axis)
If the circle centre is near the maximum (or minimum) x, and it will
likely intercept the branch for y<0, then switch x by y and a by b (i.e
rotate the axis), compute, and switch back.
You can *probably* (I have not checked anything) improve the
approximation with a correction, k at the equations for xi, as in
xi = x0 +/- k*r/sqrt(1+m**2)
with k less but close to 1.
Obviously it has the downside of being an approximation, but on the
other hand it is a closed form solution, without iterations. If not for
anything else, it could be a good stating point for a more accurate
iterative solution.
--
{ricardo from
kozmate.net}