We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › connecting rectangles with arrows
Pages: 1 2 
connecting rectangles with arrows (Read 5092 times)
Re: connecting rectangles with arrows
Reply #15 - Apr 2nd, 2010, 7:52am
 
so you're doing some sort of "flowchart layout" or something equivalent?

i'd break the problem down into several discrete tasks:

1) given the endpoints, draw a line between with optional arrows.  this is a trivial drawing task, and i'll assume prior posts have adequately addressed it.

2) given a rectangle, find *some* point on it's perimter.  this boils down to 4 line intersection tests, and one of tfguy's posts adequately solves it for the axis-aligned case.  (you'd only need fancier line intersection tests if your boxes were rotated or irregular quadrangles)

3) given two rectangles, find "correlated" connection points on their perimeter.  easiest approach is to use the line connecting their centroids, but with arbitrary placement of arbitrary aspect rectangles this would rarely be the closest pair (shortest connecting segment).  another approach is to pick any connection points you like (like limit to closest edge centers, fe), then make up for that with more elaborate (ie, maze-like) connection lines.

4) given a bunch of rectangles and their connecting lines, layout and route them all so as to avoid overlap.  it's not a trivial task, but possible.  depending on your experience, at this point you may be better off finding a third-party library that already does it (maybe the grappa port of att's graphviz?) and spend your efforts learning how to integrate it rather than how to reinvent it.

hth
Re: connecting rectangles with arrows
Reply #16 - Apr 2nd, 2010, 10:35am
 
there is a collection of all kind of intersection tests made by casey on openprocessing.org

http://www.openprocessing.org/portal/?userID=54
Re: connecting rectangles with arrows
Reply #17 - Apr 2nd, 2010, 11:27am
 
Ricard Marxer's Geomerative library http://www.ricardmarxer.com/geomerative/ would be my suggestion if fancier intersection tests are required, because you'll need to know where the intersection(s) occurs, not just if it occurs.
Pages: 1 2