Jump to content

  • Log In with Google      Sign In   
  • Create Account

polynomial intersection


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
11 replies to this topic

#1 ATMResearcher   Members   -  Reputation: 107

Like
0Likes
Like

Posted 29 July 2012 - 04:26 PM

Hi all,
I’m doing some university work based around aircraft in the air traffic system and I’m looking to use a lot of geometrical math typically found in game development. Right now, I'm trying to find out if an aircraft trajectory path intersects a circle in 2D. My path is defined by 7th degree x and y polynomials parameterised by time. The distance between the circle (Coordinates , and radius r)and the x,y trajectory path is then





By setting d(t) to zero and finding the roots of the equation I can find either the intersection time or the closest point of approach time between the path and the circle. However, to find the roots of the equation, which factors out to be a 14th degree polynomial, I have to use a numerical root finder. Are there analytical or simply better ways of finding the time of intersection between a trajectory path and a circle?? Also, what if I wanted to find the time of intersection between a trajectory and a rotated rectangle/ square? Can I do it with simple math, such as the root finding approach I used above, or do I need an algorithms with if statements etc? I've seen people here recommend the GJK algorithm, so I'll try that next. Any recommendatins, pointers or suggestions would be warmly received.

Sponsor:

#2 jjd   Crossbones+   -  Reputation: 2075

Like
1Likes
Like

Posted 29 July 2012 - 04:55 PM

There might be a great reason for using a 7th order polynomial, but this is the thing that I would discard first. Replace it with a simple linear, piece-wise curve and then your intersection problem becomes a set of simple intersection tests between line-segments and a circle. Once you get that working you can refine the approximation of the curve.

-Josh

--www.physicaluncertainty.com
--linkedin
--irc.freenode.net#gdnet


#3 jefferytitan   Crossbones+   -  Reputation: 2101

Like
1Likes
Like

Posted 29 July 2012 - 05:02 PM

In general I don't believe there's an analytical solution to polynomials anywhere near that complicated. However it occurs to me that if you could provide limits on the values of t, a bounding box could be estimated very easily. To get a minimum limit on x, put the lower value of the t range in all positive terms, and the maximum value of the t range in all negative terms. Similarly you could create quick and easy values for max x, min y and max y. If this box doesn't intersect the circle, done.

#4 ATMResearcher   Members   -  Reputation: 107

Like
0Likes
Like

Posted 29 July 2012 - 05:46 PM

Thanks Josh,
I did have a few thoughts along the lines you suggested. I guess I was hoping that there might be some special properties of polynomials that I could take advantage of to help simplify the problem.

I'm essentially doing a trajectory optimization problem. For these sorts of problems the aircraft's positions, speeds and accelerations are represented by a series of linked linear segments (like you suggested) or by polynomials. Polynomials are more accurate at representing the changes in the position and speeds of things with time, but linear segments can come with a lot fewer headaches. I might have to just keep it simple this time. Cheers!!

#5 ATMResearcher   Members   -  Reputation: 107

Like
0Likes
Like

Posted 29 July 2012 - 06:16 PM

Thanks Jeffrey Titan, I was going to chop up my trajectory with lots of discrete points and then measure the distances from the points on the line to bounding boxes to determine if I needed to run a more detailed collision detection. However I do have knowledge of my max time and yes I could use that as an initial bounding box to eliminate spatial areas that will never interact with my trajectory. As a first cut, it should definitely save me some computational time.


I've been reading these forums for a while now, I should have asked some questions sooner.

#6 jefferytitan   Crossbones+   -  Reputation: 2101

Like
1Likes
Like

Posted 29 July 2012 - 07:41 PM

I had a thought on tightening the bounds on the box that I suggested. My previous method looks at each term of the polynomial individually. Terms can be grouped, as long as the max/min for each group can be calculated analytically.

For example, our original equation is:
x = at^7 + bt^6 + ct^5 + dt^4 + et^3 + ft^2 + gt + h

We then extract two groups out of it:
x = at^7 + (bt^6 + ct^5 + dt^4) + (et^3 + ft^2 + gx) + h
x = at^7 + t^4(bt^2 + ct + d) + t(et^2 + ft + g) + h

We can analytically find the min and max values of the bcd and efg groups in the appropriate range of t values. As per my previous approach we fudge the at^7, t^4 and t terms using t(min) and t(max) as appropriate. And h is constant, so... yeah.

My other thought is whether it would be possible to find two linear, quadratic or stepwise equations which are guaranteed to upper and lower bound your function, because they might give a much tighter bound than a box.

Edit:

I thought of a quadratic bounding approach which I'm kicking myself over for not noticing before. Use fgh as your quadratic, then use estimates based on all the other terms as a big constant. The estimate could be based on t^6 times the linear equation (at + b) and t^3 times the quadratic equation (ct^2 + dt + e). It may also work if you break it up the other way, e.g. quadratic in abc times a constant approximation for t^5.

Edited by jefferytitan, 29 July 2012 - 07:54 PM.


#7 Álvaro   Crossbones+   -  Reputation: 13291

Like
0Likes
Like

Posted 29 July 2012 - 09:13 PM

This idea of bounding groups of terms in an expression seems quite unorthodox. The minima and the maxima of the different pieces will not line up, so I can't see how this helps at all.

The roots of a polynomial equation of degree 5 of larger cannot generally be expressed using a closed formula involving +,-,*,/ and taking roots (the precise statement of the theorem is more complicated, but look up Galois Theory if you are interested). This means that numeric approximations will have to do. The good news is that numeric approximations for this type of problem work very well in practice, and a lot of people have worked on this problem before.

#8 jefferytitan   Crossbones+   -  Reputation: 2101

Like
0Likes
Like

Posted 29 July 2012 - 09:34 PM

@alvaro: Agreed that it is unorthodox, however the OPs particular request has some special features: a limitation on the range of t, more than one dimension, existence of roots rather than their values, and lastly the OP asked for an analytical solution. Also based upon my guesses on the purpose of this, a bounding approach could be easily extended for multiple circles, or for a z dimension as well. It doesn't give an exact answer, but if it works as I imagined it gives certainty from one angle (if it's not within the bounding area there is no possibility of intersection), and for an exact answer I'd hand over to numerical methods.

#9 Álvaro   Crossbones+   -  Reputation: 13291

Like
1Likes
Like

Posted 29 July 2012 - 10:07 PM

@alvaro: Agreed that it is unorthodox, however the OPs particular request has some special features: a limitation on the range of t, more than one dimension, existence of roots rather than their values, and lastly the OP asked for an analytical solution.

Oh, I missed the part where he is not interested in the values of the roots. The number of real roots of a polynomial in an interval can be computed using Sturm's theorem. Perhaps that's all the OP needed?

EDIT: Hmmm... Silly link bug... This should work: http://en.wikipedia.org/wiki/Sturm%27s_theorem

#10 jefferytitan   Crossbones+   -  Reputation: 2101

Like
0Likes
Like

Posted 29 July 2012 - 10:25 PM

@alvaro: Interesting, I hadn't heard of Sturm's theorem. I'm not positive that he doesn't require the values of the roots, but that's how I read it. I think your link got truncated, link below:

http://en.wikipedia....m's_theorem

Edit: Oh Sturm, you and your apostrophe. I'm not going to try any more. Posted Image

Edited by jefferytitan, 29 July 2012 - 10:45 PM.


#11 ATMResearcher   Members   -  Reputation: 107

Like
0Likes
Like

Posted 30 July 2012 - 11:33 AM

Thanks for the input guys. To clear things up, I am interested in the root values, but not always. The circles intersecting my trajectory can either be obstacles to be avoided or waypoints to be followed. For the obstacles I just need to know if the obstacle is avoided. For the waypoint case I need to know if the waypoint is crossed, and if not, I want to know the Closest Point of Approach between the trajectory and the waypoint. You see I make some corrections to the polynomials based on the CPA to move them closer to the waypoints. If there is no intersection between the waypoint and the polynomials, then the complex root of the equation below will give the time of CPA and hence the CPA.



I have already tried Sturm, and it works. It can also be used recursively to find the roots. It does require a lot of convolution and deconvolution though (polynomial multiplication and division) and gets quite time consuming quite quickly.

Another thing I’ve tried is Chebfun, which generates a polynomial expansion of a function. It can be used to find the roots of a polynomial of any degree. It’s not analytical but it’s quite accurate. Again the computation time is a higher than I would like.

For Sturm and Chebfun, I don’t think there is any great advantage in using them over numerical root finders for my particular problem. JeffreyTitan your quadratic suggestion looks interesting, I’ll plug some numbers in to see what I think. Otherwise I think I’ll do something similar to what Josh suggested and break my trajectory into lots of small linear segments. This should keep things fast and the loss of accuracy should be minimal.

#12 jefferytitan   Crossbones+   -  Reputation: 2101

Like
0Likes
Like

Posted 30 July 2012 - 04:50 PM

Thanks for updating us on your progress, always good to hear how it goes. Keep in mind that my suggestion was invented on the spot and is a bound only. But I'd be curious to know if/how much it worked. I'm too busy with my own projects to test it out. ;)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS