本文へ移動

@eightkk/vue-weave / core / findOrthogonalRoute

Function: findOrthogonalRoute() ​

findOrthogonalRoute(from, to, obstacles, options?): GraphPoint[] | undefined

Defined in: src/core/graphObstacleRouting.ts:478

Finds an axis-aligned route from from to to that keeps clearance (default 8) away from every obstacle rectangle, leaving from and entering to perpendicular to their sides (with a clearance of 0 the route may run along the border of an end's own node, which only costs extra). Include the boxes of the two end nodes in obstacles: the route then never runs through them. The route minimises its length plus bendPenalty (default 24) per bend, and is deterministic for the same input. Returns the polyline from from to to, or undefined when no route exists or the bounded search gives up. When every input lies at nonnegative coordinates, so does the route.

The search runs over a sparse grid: lines halfway between neighbouring obstacle edges (the middle of each free channel) and through both ends, never a pixel grid. Obstacles go into a bucket grid in O(n); the search starts in a region around both ends and grows it fourfold up to the whole area, each round taking O(k log k) for the k obstacles in the region plus A* over at most 4·lx·ly states for lx by ly lines, capped at 200,000 expanded states.

Throws RangeError for a non-finite end, an unknown side, an obstacle with non-finite coordinates or a negative or non-finite size, and a negative or non-finite clearance or bend penalty.

Parameters ​

from ​

GraphRouteEnd

to ​

GraphRouteEnd

obstacles ​

readonly GraphRect[]

options? ​

GraphObstacleAvoidance = {}

Returns ​

GraphPoint[] | undefined

MIT ライセンスで公開しています。