Results 1 to 5 of 5

Thread: how do i know if two lines intersect?

  1. #1
    Join Date
    Sep 2008
    Location
    Slovakia, Nitra
    Posts
    15
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question how do i know if two lines intersect?

    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?!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how do i know if two lines intersect?

    You'll have to do proper math calculations using the y=ax+b formula.

  3. The following user says thank you to wysota for this useful post:

    Vincenzo (7th November 2008)

  4. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how do i know if two lines intersect?

    You could use QPainterPath::intersects(), but that's probably an overkill.

  5. #4
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    506
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how do i know if two lines intersect?

    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

  6. #5
    Join Date
    Sep 2008
    Location
    Slovakia, Nitra
    Posts
    15
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how do i know if two lines intersect?

    ...I thought there is some function in Qt...
    But I did it with math calculation like you told me, and now it works...

Similar Threads

  1. I want to get lines of text
    By newplayer in forum Qt Programming
    Replies: 11
    Last Post: 29th July 2008, 09:03
  2. Display QLabel in two lines
    By arunvv in forum Newbie
    Replies: 1
    Last Post: 8th February 2008, 05:25
  3. how to show vertical lines between colums
    By thomasjoy in forum Qt Programming
    Replies: 4
    Last Post: 22nd August 2007, 15:03
  4. Removing and Redrawing Lines in a QGraphicsScene in PyQT
    By giverson in forum Qt Programming
    Replies: 1
    Last Post: 26th February 2007, 20:23
  5. How to draw lines with the right width?
    By albanelporto in forum Qt Programming
    Replies: 3
    Last Post: 22nd November 2006, 11:51

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.