Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Drawing Lines

Drawing Lines

Scheduled Pinned Locked Moved C / C++ / MFC
helpgraphicsdesign
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vijayaramaraju
    wrote on last edited by
    #1

    Hi, I'm developing an application where you can configure circuits. the problem is after placing the components on the User Interface I've to make connections. these connections are to be represented by lines. How do we caluclate the path of a line that does not pass through a certain Area . The lines can be only horizontal or vertical. The line has to pass around a certain specified area. can anybody help me out with this thanks, in advance

    C P 2 Replies Last reply
    0
    • V vijayaramaraju

      Hi, I'm developing an application where you can configure circuits. the problem is after placing the components on the User Interface I've to make connections. these connections are to be represented by lines. How do we caluclate the path of a line that does not pass through a certain Area . The lines can be only horizontal or vertical. The line has to pass around a certain specified area. can anybody help me out with this thanks, in advance

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You're trying to get the circuit to draw itself and therefore not cross ? A basic line intersection algorithm looks like this: function ccw(p1, p2, p3) // Slightly deficient function to determine if the two lines p1, p2 and // p2, p3 turn in counter clockwise direction} { var dx1, dx2, dy1, dy2; dx1 = p2.x - p1.x; dy1 = p2.y - p1.y; dx2 = p3.x - p2.x; dy2 = p3.y - p2.y; if (dy1/dx1 < dy2/dx2) return true; else return false; } function intersect(l1, l2) { return ((ccw(l1.p1, l1.p2, l2.p1) != ccw(l1.p1, l1.p2, l2.p2)) && (ccw(l2.p1, l2.p2, l1.p1) != ccw(l2.p1, l2.p2, l1.p2))); } That's in JScript, sorry. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002

      S 1 Reply Last reply
      0
      • C Christian Graus

        You're trying to get the circuit to draw itself and therefore not cross ? A basic line intersection algorithm looks like this: function ccw(p1, p2, p3) // Slightly deficient function to determine if the two lines p1, p2 and // p2, p3 turn in counter clockwise direction} { var dx1, dx2, dy1, dy2; dx1 = p2.x - p1.x; dy1 = p2.y - p1.y; dx2 = p3.x - p2.x; dy2 = p3.y - p2.y; if (dy1/dx1 < dy2/dx2) return true; else return false; } function intersect(l1, l2) { return ((ccw(l1.p1, l1.p2, l2.p1) != ccw(l1.p1, l1.p2, l2.p2)) && (ccw(l2.p1, l2.p2, l1.p1) != ccw(l2.p1, l2.p2, l1.p2))); } That's in JScript, sorry. Christian No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002 Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002 During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002

        S Offline
        S Offline
        Stephane Rodriguez
        wrote on last edited by
        #3

        Oh I recognize the asteroids guy here...;P


        How low can you go ?
        (MS rant)

        1 Reply Last reply
        0
        • V vijayaramaraju

          Hi, I'm developing an application where you can configure circuits. the problem is after placing the components on the User Interface I've to make connections. these connections are to be represented by lines. How do we caluclate the path of a line that does not pass through a certain Area . The lines can be only horizontal or vertical. The line has to pass around a certain specified area. can anybody help me out with this thanks, in advance

          P Offline
          P Offline
          Paul M Watt
          wrote on last edited by
          #4

          If you simply want to avoid your lines from crossing, then Christian Graus's solution would work fine. However I think this solution will limit you to very simple layout diagrams. If you would like your tool to be able to layout complex paths, I would suggest looking up path-finding on Google. I have seen many sample applications, you may be able to find one that will work for you. Good Luck


          Build a man a fire, and he will be warm for a day
          Light a man on fire, and he will be warm for the rest of his life!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups