PDA

View Full Version : how do i know if two lines intersect?



Vincenzo
1st November 2008, 08:48
I checked member functions of QLine, but there is no function/solution to this problem. I have two lines and if this two lines intersect than i want for return bool value - is it possible some easy way?!

wysota
1st November 2008, 10:05
You'll have to do proper math calculations using the y=ax+b formula.

jacek
3rd November 2008, 01:46
You could use QPainterPath::intersects(), but that's probably an overkill.

Ginsengelf
3rd November 2008, 06:56
Hi, if you use 2D, two lines will intersect somewhere, if the "a" in wysota's formula is different for both lines, otherwise they are parallel. In 3D it's a different thing...

Ginsengelf

Vincenzo
7th November 2008, 14:23
...I thought there is some function in Qt...
But I did it with math calculation like you told me, and now it works... :)