RectangularPathFinder
Class which finds rectangular path, i.e. path with 90 degrees turns, between two boxes.
Configs
9
Configs
9Default end arrow staff size in pixels
Default ending connection point shift from box's arrow pointing side middle point
Default end arrow pointing direction, possible values are: 'left', 'right', 'top', 'bottom'
Start / End box horizontal margin, the amount of pixels from left and right line of a box where drawing
Other rectangular areas (obstacles) to search path through
Default start arrow staff size in pixels
Default starting connection point shift from box's arrow pointing side middle point
Default start connection side: 'left', 'right', 'top', 'bottom'
Start / End box vertical margin, the amount of pixels from top and bottom line of a box where drawing is prohibited
Functions
1
Functions
1Returns list of horizontal and vertical segments connecting two boxes
| | | | | | --+----+----+----*-------*--- --+=>Start +----*-------*-- --+----+----+----*-------*-- | | | | | | | | | | | | --*----*-+-------+-------+-- --*----*-+ End <=+-- --*----*-+-------+-------+-- | | | | | |
Path goes by lines (-=) and turns at intersections (+), boxes depicted are adjusted by horizontal/vertical margin and arrow margin, original boxes are smaller (path can't go at original box borders). Algorithm finds the shortest path with minimum amount of turns. In short it's mix of "Lee" and "Dijkstra pathfinding" with turns amount taken into account for distance calculation.
The algorithm is not very performant though, it's O(N^2), where N is amount of points in the grid, but since the maximum amount of points in the grid might be up to 34 (not 36 since two box middle points are not permitted) that might be ok for now.
| Parameter | Type | Description |
|---|---|---|
lineDef | Object | An object containing any of the class configuration option overrides as well
as |
lineDef.startBox | Object | An object containing |
lineDef.endBox | Object | An object containing |
lineDef.startHorizontalMargin | Number | Horizontal margin override for start box |
lineDef.startVerticalMargin | Number | Vertical margin override for start box |
lineDef.endHorizontalMargin | Number | Horizontal margin override for end box |
lineDef.endVerticalMargin | Number | Vertical margin override for end box |
Array of line segments or false if path cannot be found