Click to See Complete Forum and Search --> : Line Algorithm


pvijayaramaraju
October 30th, 2002, 04:59 AM
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 :confused: . 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

agni256
October 31st, 2002, 10:23 AM
I think it would be a design and the algol..
My suggestion would be to keep a method of

List of Nearest Components = FindNearestComponet(Newly added component)

Now for each Nearest Component
CPoint ConnectionPoint = GetConnectionPoints(component)

You now need to find out the breaking of straight line into
horizontal and vertical line.
(x1, y1) to (x2, y2)
which I think you need to do lot if and else calc. Taking for e.g.
x1 < x2 and y1<y2 and x1<=y1 <x2<=y2
find the mid-point (y1+y2)/2
Draw x2, midpoint to x2, y2
Draw x1, midpoint to x2, midpoint
Draw x1, y1 to x1, midpoint

We are trying to draw a diagnol line to a set of straight lines.
Please make sure the the slopes of line that you drawing..