distanceTo(shape) {
        // let {Distance} = Flatten;

        if (shape instanceof Flatten.Point) {
            let [dist, shortest_segment] = Flatten.Distance.point2polygon(shape, this);
            shortest_segment = shortest_segment.reverse();
            return [dist, shortest_segment];
        }

        if (shape instanceof Flatten.Circle ||
            shape instanceof Flatten.Line ||
            shape instanceof Flatten.Segment ||
            shape instanceof Flatten.Arc) {
            let [dist, shortest_segment] = Flatten.Distance.shape2polygon(shape, this);
            shortest_segment = shortest_segment.reverse();
            return [dist, shortest_segment];
        }

        /* this method is bit faster */
        if (shape instanceof Flatten.Polygon) {
            let min_dist_and_segment = [Number.POSITIVE_INFINITY, new Flatten.Segment()];
            let dist, shortest_segment;

            for (let edge of this.edges) {
                // let [dist, shortest_segment] = Distance.shape2polygon(edge.shape, shape);
                let min_stop = min_dist_and_segment[0];
                [dist, shortest_segment] = Flatten.Distance.shape2planarSet(edge.shape, shape.edges, min_stop);
                if (Flatten.Utils.LT(dist, min_stop)) {
                    min_dist_and_segment = [dist, shortest_segment];
                }
            }
            return min_dist_and_segment;
        }
    }
/**
     * Return distance and shortest segment between polygon and other shape as array [distance, shortest_segment]
     * @param {Shape} shape Shape of one of the types Point, Circle, Line, Segment, Arc or Polygon
     * @returns {Number | Segment}
     */
Return distance and shortest segment between polygon and other shape as array [distance, shortest_segment]
@param {Shape} shape Shape of one of the types Point, Circle, Line, Segment, Arc or Polygon
@returns {Number | Segment}
Return distance and shortest segment between polygon and other shape as array [ distance shortest_segment ] @param { Shape } shape Shape of one of the types Point Circle Line Segment Arc or Polygon @returns { Number | Segment }
distanceTo(shape) {
        if (shape instanceof Flatten.Point) {
            let [dist, shortest_segment] = Flatten.Distance.point2polygon(shape, this);
            shortest_segment = shortest_segment.reverse();
            return [dist, shortest_segment];
        }
        if (shape instanceof Flatten.Circle ||
            shape instanceof Flatten.Line ||
            shape instanceof Flatten.Segment ||
            shape instanceof Flatten.Arc) {
            let [dist, shortest_segment] = Flatten.Distance.shape2polygon(shape, this);
            shortest_segment = shortest_segment.reverse();
            return [dist, shortest_segment];
        }
        if (shape instanceof Flatten.Polygon) {
            let min_dist_and_segment = [Number.POSITIVE_INFINITY, new Flatten.Segment()];
            let dist, shortest_segment;
            for (let edge of this.edges) {
                let min_stop = min_dist_and_segment[0];
                [dist, shortest_segment] = Flatten.Distance.shape2planarSet(edge.shape, shape.edges, min_stop);
                if (Flatten.Utils.LT(dist, min_stop)) {
                    min_dist_and_segment = [dist, shortest_segment];
                }
            }
            return min_dist_and_segment;
        }
    }
distanceTo ( shape ) { if ( shape instanceof Flatten . Point ) { let [ dist , shortest_segment ] = Flatten . Distance . point2polygon ( shape , this ) ; shortest_segment = shortest_segment . reverse ( ) ; return [ dist , shortest_segment ] ; } if ( shape instanceof Flatten . Circle || shape instanceof Flatten . Line || shape instanceof Flatten . Segment || shape instanceof Flatten . Arc ) { let [ dist , shortest_segment ] = Flatten . Distance . shape2polygon ( shape , this ) ; shortest_segment = shortest_segment . reverse ( ) ; return [ dist , shortest_segment ] ; } if ( shape instanceof Flatten . Polygon ) { let min_dist_and_segment = [ Number . POSITIVE_INFINITY , new Flatten . Segment ( ) ] ; let dist , shortest_segment ; for ( let edge of this . edges ) { let min_stop = min_dist_and_segment [ 0 ] ; [ dist , shortest_segment ] = Flatten . Distance . shape2planarSet ( edge . shape , shape . edges , min_stop ) ; if ( Flatten . Utils . LT ( dist , min_stop ) ) { min_dist_and_segment = [ dist , shortest_segment ] ; } } return min_dist_and_segment ; } }
Return distance and shortest segment between polygon and other shape as array [distance, shortest_segment]
 @param {Shape} shape Shape of one of the types Point, Circle, Line, Segment, Arc or Polygon
 @returns {Number | Segment}
Return distance and shortest segment between polygon and other shape as array [ distance shortest_segment ] @param { Shape } shape Shape of one of the types Point Circle Line Segment Arc or Polygon @returns { Number | Segment }
// let {Distance} = Flatten; /* this method is bit faster */ // let [dist, shortest_segment] = Distance.shape2polygon(edge.shape, shape);