Results 1 to 3 of 3

Thread: QGraphicsItem; Finding path

  1. #1
    Join Date
    Feb 2011
    Posts
    20
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QGraphicsItem; Finding path

    I've created a simple image to demonstrate my problem and hopefully someone can give me some hints or tips on how to solve this.

    As you can see in the image there is three lines. The blue line is a polyline that intersects with the black line. The red one is exactly the same as the blue except for that it intersects with two lines(The blue and the black line). I'm having serious problem figuring out how I can find the intersected path for the red line. I hope someone can help me figuring this out.
    Attached Images Attached Images

  2. #2
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsItem; Finding path

    You could look up 'polygon intersection'; there are several algorithms. The most efficient approach would likely be a variant of a scan-line algorithm. If there are never more than a few segments per line, though, a more brute-force approach of checking every pair of segments between two lines for intersection would probably work just fine and be simpler to implement than scan-line. As the number of segments grows, however, the number of comparisons grows as n^2, so such an approach quickly becomes too slow to be practical. For a dozen or so segments, though, speed ought to be fine.

  3. #3
    Join Date
    Feb 2011
    Posts
    20
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QGraphicsItem; Finding path

    Thank you for the hints SixDegrees! I have found a library that is called generic polygon clipper but I'm not sure this is what I need. But I will try it out

Similar Threads

  1. Replies: 7
    Last Post: 29th November 2010, 19:20
  2. Replies: 8
    Last Post: 17th October 2009, 08:10
  3. Finding Files
    By arbi in forum Qt Programming
    Replies: 4
    Last Post: 21st August 2009, 14:30
  4. Finding widget by name
    By mkarakaplan in forum Newbie
    Replies: 1
    Last Post: 9th December 2007, 17:38

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.