5

I'm trying to write a program which finds the intersections between an arbitrary sine wave and an arbitrary sized and placed circle, in Cartesian coordinates, but I'm stuck with the math.

Here's a graphical example of the kind of intersections that I need to find: Example

I tried to mix both sine: $$y(x)=A\sin\left(\frac{2\pi}{T}x+\phi\right)$$ and circle equations: $$(x-\alpha)^2 + (y-\beta)^2 = r^2$$

But I don't get the right values. Besides, I can only define two points using the equalization and substitution methods, and if you look at the example, there are lots of intersections on the same circle.

What's the correct equation that I should use? And how get the different points defined?

$\mathbf{EDIT:}$

I already used this method trying to find intersections, and then I get and solve a quadratic equation, but this doesn't work: $$x^2-2\alpha x+\alpha^2+y^2-2\beta y+\beta^2 = r^2$$ $$x^2+\left(A\sin\left(\frac{2\pi}{T}x+\phi\right)\right)^2-2\alpha x-2\beta \left(A\sin\left(\frac{2\pi}{T}x+\phi\right)\right)+\alpha^2+\beta^2-r^2 = 0$$

Chaos
  • 151
  • 3
    You won't get closed-form solutions. Numerical methods, e.g. Newton's method, can be used. I might suggest using a parametric representation for the circle. – Robert Israel Mar 08 '17 at 06:22
  • I edited my question. If you still think the same thing, could you elaborate please? Thanks. – Chaos Mar 08 '17 at 15:07
  • You can't. Try the simplest case that is intersection of sinx and a circle centered at origin. You 'll get a hopeless equation. – Sawarnik Mar 08 '17 at 15:32
  • I did that to simplify things, but the results are still wrong. – Chaos Mar 08 '17 at 15:43

2 Answers2

1

As was discussed in the comments, there's no way to find the points of intersection analytically; numerical methods are your only option. Newton's method is a great place to start.

As an example (taken from Sawarnik's comment), consider the points of intersection of the circle $x^2+y^2=1$ and the sine wave $y=\sin x$. Plugging the second equation into the first, you get the following equation for $x$:

$$x^2+\sin^2x-1=0$$

Frustrating though this might be (and to me, it's very frustrating), there's no way you'll be able to manipulate that equation algebraically to find the values of $x$ that satisfy it. Using Newton's method, on the other hand, it's comparatively easy to find that the solutions are $x=\pm\hspace{0.5mm}0.7391$. Any other circle/sine wave combination will produce an even more complicated equation, which would make the use of some sort of numerical method even more necessary.

1

Using Robert Howard's example, it is interesting to notice that we can make good approximation of $$f(x)=x^2+\sin^2x-1$$ building the $[4,2n]$ Padé approximant at $x=0$. This will write $$f(x)=\frac {-1+a_1^{(n)} x^2+a_2^{(n)} x^4}{1+\sum_{k=1}^n b_k x^{2k}}$$ and solving the quadratic in $x_{(n)}^2$ which appears in numerator is simple.

Considering only the smallest positive root and various $n$, we should get $$\left( \begin{array}{ccc} n & x_{(n)} & x_{(n)}\approx \\ 0 & \sqrt{3-\sqrt{6}} & 0.741964 \\ 1 & \sqrt{14-\sqrt{181}} & 0.739172 \\ 2 & \sqrt{\frac{33 \sqrt{95}-255}{122}} & 0.739097 \end{array} \right)$$ while the exact solution, obtained using Newton method, would be $0.739085$.