PDA

View Full Version : How to calculate intersection points of a curve and a line?



lni
23rd April 2009, 20:17
Hi,

I have a curve defined by QPolygonF and a line defined by QLineF.

Is there a way to calculate their intersection points in Qt, as shown in the chart?

Thanks!

mcosta
24th April 2009, 09:51
You can build an array of QLineF using the QPolygonF points and call QLineF::intersect for each line of array.

lni
24th April 2009, 17:22
You can build an array of QLineF using the QPolygonF points and call QLineF::intersect for each line of array.

Thanks. That is what I am doing right now. It is slow. I have googled around and found so-called "sweep line algorithm", wish this would be available in Qt...

http://www.google.com/search?q=sweep+line+algorithm&sourceid=navclient-ff&ie=UTF-8&rlz=1B3GGGL_enUS289US289