CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Line Algorithm

  1. #1
    Join Date
    Jul 2001
    Location
    Hyderabad,India
    Posts
    17

    Line Algorithm

    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

  2. #2
    Join Date
    Oct 2002
    Location
    Boston
    Posts
    40
    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..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured