Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code or formula for intersection of two parabolas in any rotation

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.

like image 583
Knyphe Avatar asked Sep 24 '08 20:09

Knyphe


People also ask

How many intersections can 2 parabolas have?

Answer to warmup question Or more precisely, two quadratic graphs (parabolas) can have one, two, or zero point of intersection.

How do you solve two parabolas?

If two curve intersect each other, i.e. there is at least one point common between them. Calculation: The points of intersection of the two parabolas are solutions to the simultaneous equations y = -(x + 1) 2 + 3 and y = x 2 - 3x + 2. x = 1/2 and x = 0.

Can two parabolas intersect at 4 points?

Therefore, the two parabolas do not intersect at four distinct points.


2 Answers

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.

like image 64
Nils Pipenbrinck Avatar answered Oct 03 '22 12:10

Nils Pipenbrinck


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).

like image 33
xaq Avatar answered Oct 03 '22 13:10

xaq