Code or formula for intersection of two parabolas in any rotation

此生再无相见时 提交于 2019-12-07 04:37:47

问题


I am working on a geometry problem that requires finding the intersection of two parabolic arcs in any rotation. I was able to intesect a line and a parabolic arc by rotating the plane to align the arc with an axis, but two parabolas cannot both align with an axis. I am working on deriving the formulas, but I would like to know if there is a resource already available for this.


回答1:


I'd first define the equation for the parabolic arc in 2D without rotations:

  x(t) = ax² + bx + c
  y(t) = t;

You can now apply the rotation by building a rotation matrix:

  s = sin(angle)
  c = cos(angle)

  matrix = | c -s |
           | s  c |

Apply that matrix and you'll get the rotated parametric equation:

x' (t) = x(t) * c - s*t;
y' (t) = x(t) * s + c*t;

This will give you two equations (for x and y) of your parabolic arcs.

Do that for both of your rotated arcs and subtract them. This gives you an equation like this:

  xa'(t) = rotated equation of arc1 in x
  ya'(t) = rotated equation of arc1 in y.
  xb'(t) = rotated equation of arc2 in x
  yb'(t) = rotated equation of arc2 in y.
  t1 = parametric value of arc1
  t2 = parametric value of arc2

  0 = xa'(t1) - xb'(t2)
  0 = ya'(t1) - yb'(t2)

Each of these equation is just a order 2 polynomial. These are easy to solve.

To find the intersection points you solve the above equation (e.g. find the roots).

You'll get up to two roots for each axis. Any root that is equal on x and y is an intersection point between the curves.

Getting the position is easy now: Just plug the root into your parametric equation and you can directly get x and y.




回答2:


Unfortunately, the general answer requires solution of a fourth-order polynomial. If we transform coordinates so one of the two parabolas is in the standard form y=x^2, then the second parabola satisfies (ax+by)^2+cx+dy+e==0. To find the intersection, solve both simultaneously. Substituting in y=x^2 we see that the result is a fourth-order polynomial: (ax+bx^2)^2+cx+dx^2+e==0. Nils solution therefore won't work (his mistake: each one is a 2nd order polynomial in each variable separately, but together they're not).




回答3:


It's easy if you have a CAS at hand.

See the solution in Mathematica.

Choose one parabola and change coordinates so its equation becomes y(x)=a x^2 (Normal form).

The other parabola will have the general form:

A x^2 + B x y + CC y^2 + DD x + EE y + F == 0 

where B^2-4 A C ==0 (so it's a parabola)  

Let's solve a numeric case:

p = {a -> 1, A -> 1, B -> 2, CC -> 1, DD -> 1, EE -> -1, F -> 1};
p1 = {ToRules@N@Reduce[
       (A x^2 + B x y + CC y^2 + DD x + EE y +F /. {y -> a x^2 } /. p) == 0, x]}

{{x -> -2.11769}, {x -> -0.641445}, {x -> 0.379567- 0.76948 I}, {x -> 0.379567+ 0.76948 I}}

Let's plot it:

Show[{
  Plot[a x^2 /. p, {x, -10, 10}, PlotRange -> {{-10, 10}, {-5, 5}}], 
  ContourPlot[(A x^2 + B x y + CC y^2 + DD x + EE y + F /. p) == 
    0, {x, -10, 10}, {y, -10, 10}],
  Graphics[{
    PointSize[Large], Pink, Point[{x, x^2} /. p /. p1[[1]]],
    PointSize[Large], Pink, Point[{x, x^2} /. p /. p1[[2]]]
    }]}]

The general solution involves calculating the roots of:

4 A F + 4 A DD x + (4 A^2 + 4 a A EE) x^2 + 4 a A B x^3 + a^2 B^2 x^4 == 0  

Which is done easily in any CAS.



来源:https://stackoverflow.com/questions/129815/code-or-formula-for-intersection-of-two-parabolas-in-any-rotation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!