Drawing Lines
-
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
-
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
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
-
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
Oh I recognize the asteroids guy here...;P
How low can you go ?
(MS rant) -
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
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!