metro
Schematizes this Shape in the style of a metro map: every contour is replaced by a polyline whose segments are all parallel to one of directions evenly spaced directions. See ShapeContour.metro.
Schematizes this ShapeContour in the style of a metro map: the contour is replaced by a polyline whose segments are all parallel to one of directions evenly spaced directions (2: rectilinear, 3: hexilinear, 4: octilinear).
The contour is linearized using ShapeContour.sampleLinear, optionally subdivided to a spacing of at most samplingDistance, after which the vertices are fitted using metro.
Parameters
the number of allowed segment directions, evenly spread over 180 degrees
rotation of the allowed directions in degrees
cost per output segment, in squared distance units, see metro
weight of the segment length error, see metro
the distance tolerance used to linearize curved segments
the maximum spacing of the fitted points, the default only uses the linearized vertices
Fits a polyline with segments in a limited set of directions to this sequence of points, using the path schematisation heuristic described in Dwyer, Hurst and Merrick, "A Fast and Simple Heuristic for Metro Map Path Simplification" (ISVC 2008).
The points are partitioned into blocks of consecutive points, starting with blocks of two points. Each block is fitted with the least-squares line through its barycenter in the best of the allowed directions. Adjacent blocks share their end point. Adjacent blocks with parallel lines are merged until no parallel neighbours remain. The vertices of the output are the intersections of the lines of adjacent blocks; the first and last vertex of an open path are the projections of the first and last point onto their block lines.
When segmentPenalty or boundsWeight is positive, adjacent blocks are then greedily merged as long as that lowers the cost function
cost = segmentPenalty * m + sum(regression(B) + boundsWeight * bounds(B))
where m is the number of blocks, regression(B) the sum of squared distances between the points of block B and its line and bounds(B) the squared distance between the ends of the segment of B and the extent of its points along the line. This is equation 2 of the paper with alpha = segmentPenalty * n and beta = 1.
Return
the vertices of the schematized polyline, for closed input the last vertex is not repeated
Parameters
whether the points describe a closed loop
the number of allowed segment directions, evenly spread over 180 degrees
rotation of the allowed directions in degrees
cost per output segment, in squared distance units; larger values give simpler paths
weight of the segment length error; positive values remove short segments that fit poorly