Returns flattened length of the curve with precision better than `opt.precision`; or using `opt.subdivisions` provided.
555408
function(opt) {

            opt = opt || {};
            var precision = (opt.precision === undefined) ? this.PRECISION : opt.precision; // opt.precision only used in getSubdivisions() call
            var subdivisions = (opt.subdivisions === undefined) ? this.getSubdivisions({ precision: precision }) : opt.subdivisions;
            // not using localOpt

            var length = 0;
            var n = subdivisions.length;
            for (var i = 0; i < n; i++) {

                var currentSubdivision = subdivisions[i];
                length += currentSubdivision.endpointDistance();
            }

            return length;
        }
1019353
def round_geom(geom, precision=None):
    """"""
    if geom['type'] == 'Point':
        x, y = geom['coordinates']
        xp, yp = [x], [y]
        if precision is not None:
            xp = [round(v, precision) for v in xp]
            yp = [round(v, precision) for v in yp]
        new_coords = tuple(zip(xp, yp))[0]
    if geom['type'] in ['LineString', 'MultiPoint']:
        xp, yp = zip(*geom['coordinates'])
        if precision is not None:
            xp = [round(v, precision) for v in xp]
            yp = [round(v, precision) for v in yp]
        new_coords = tuple(zip(xp, yp))
    elif geom['type'] in ['Polygon', 'MultiLineString']:
        new_coords = []
        for piece in geom['coordinates']:
            xp, yp = zip(*piece)
            if precision is not None:
                xp = [round(v, precision) for v in xp]
                yp = [round(v, precision) for v in yp]
            new_coords.append(tuple(zip(xp, yp)))
    elif geom['type'] == 'MultiPolygon':
        parts = geom['coordinates']
        new_coords = []
        for part in parts:
            inner_coords = []
            for ring in part:
                xp, yp = zip(*ring)
                if precision is not None:
                    xp = [round(v, precision) for v in xp]
                    yp = [round(v, precision) for v in yp]
                inner_coords.append(tuple(zip(xp, yp)))
            new_coords.append(inner_coords)
    return {'type': geom['type'], 'coordinates': new_coords}
470581
def to_flat(coord):
    """"""
    if coord is None:
        return go.N * go.N
    return go.N * coord[0] + coord[1]
879197
public double pathLengthEstimate(double... controlPoints)
    {
        double maxX = Double.NEGATIVE_INFINITY;
        double maxY = Double.NEGATIVE_INFINITY;
        double minX = Double.POSITIVE_INFINITY;
        double minY = Double.POSITIVE_INFINITY;
        for (int n=0;n<length;n++)
        {
            maxX = Math.max(maxX, controlPoints[2*n]);
            maxY = Math.max(maxY, controlPoints[2*n+1]);
            minX = Math.min(minX, controlPoints[2*n]);
            minY = Math.min(minY, controlPoints[2*n+1]);
        }
        return (maxX-minX+maxY-minY)*1.35;
    }
1218345
function length(A) {
    if (A.shape.length !== 1) {
        throw new Error('A is not a 1D array');
    }
    return Math.sqrt(dot(A, A));
}
424733
function roundToPrecision(numStr, scale, fixedDecimalScale) {
  //if number is empty don't do anything return empty string
  if (['', '-'].indexOf(numStr) !== -1) return numStr;
  var shoudHaveDecimalSeparator = numStr.indexOf('.') !== -1 && scale;

  var _splitDecimal = splitDecimal(numStr),
      beforeDecimal = _splitDecimal.beforeDecimal,
      afterDecimal = _splitDecimal.afterDecimal,
      hasNagation = _splitDecimal.hasNagation;

  var roundedDecimalParts = parseFloat("0.".concat(afterDecimal || '0')).toFixed(scale).split('.');
  var intPart = beforeDecimal.split('').reverse().reduce(function (roundedStr, current, idx) {
    if (roundedStr.length > idx) {
      return (Number(roundedStr[0]) + Number(current)).toString() + roundedStr.substring(1, roundedStr.length);
    }

    return current + roundedStr;
  }, roundedDecimalParts[0]);
  var decimalPart = limitToScale(roundedDecimalParts[1] || '', Math.min(scale, afterDecimal.length), fixedDecimalScale);
  var negation = hasNagation ? '-' : '';
  var decimalSeparator = shoudHaveDecimalSeparator ? '.' : '';
  return "".concat(negation).concat(intPart).concat(decimalSeparator).concat(decimalPart);
}
948788
function roundPrecision (x, d, places = 2) {
    return (Math.floor(x * d) / d).toFixed(places);
}
387858
public static double length3D(CoordinateSequence points) {
        // optimized for processing CoordinateSequences

        int numberOfCoords = points.size();
        // Points have no length.
        if (numberOfCoords < 2) {
            return 0.0;
        }

        Coordinate currentCoord = new Coordinate();
        points.getCoordinate(0, currentCoord);
        double x0 = currentCoord.x;
        double y0 = currentCoord.y;
        double z0 = currentCoord.z;

        double length = 0.0;
        for (int i = 1; i < numberOfCoords; i++) {
            points.getCoordinate(i, currentCoord);

            double x1 = currentCoord.x;
            double y1 = currentCoord.y;
            double z1 = currentCoord.z;

            double dx = x1 - x0;
            double dy = y1 - y0;
            double dz;

            // For 2D geometries, we want to return the 2D length.
            if (Double.isNaN(z0) || Double.isNaN(z1)) {
                dz = 0.0;
            } else {
                dz = z1 - z0;
            }

            length += Math.sqrt(dx * dx + dy * dy + dz * dz);
            x0 = x1;
            y0 = y1;
            z0 = z1;
        }
        return length;
    }
60319
def _recursive_bezier(self, x1, y1, x2, y2, x3, y3, attr, row, level=0):
        ''
        m_approximation_scale = 10.0
        m_distance_tolerance = (0.5 / m_approximation_scale) ** 2
        m_angle_tolerance = 1 * 2*math.pi/360  # 15 degrees in rads
        curve_angle_tolerance_epsilon = 0.01
        curve_recursion_limit = 32
        curve_collinearity_epsilon = 1e-30

        if level > curve_recursion_limit:
            return

        # Calculate all the mid-points of the line segments

        x12   = (x1 + x2) / 2
        y12   = (y1 + y2) / 2
        x23   = (x2 + x3) / 2
        y23   = (y2 + y3) / 2
        x123  = (x12 + x23) / 2
        y123  = (y12 + y23) / 2

        dx = x3-x1
        dy = y3-y1
        d = abs(((x2 - x3) * dy - (y2 - y3) * dx))

        if d > curve_collinearity_epsilon:
            # Regular care
            if d*d <= m_distance_tolerance * (dx*dx + dy*dy):
                # If the curvature doesn't exceed the distance_tolerance value, we tend to finish subdivisions.
                if m_angle_tolerance < curve_angle_tolerance_epsilon:
                    self.point(x123, y123, attr, row)
                    return

                # Angle & Cusp Condition
                da = abs(math.atan2(y3 - y2, x3 - x2) - math.atan2(y2 - y1, x2 - x1))
                if da >= math.pi:
                    da = 2*math.pi - da

                if da < m_angle_tolerance:
                    # Finally we can stop the recursion
                    self.point(x123, y123, attr, row)
                    return
        else:
            # Collinear case
            dx = x123 - (x1 + x3) / 2
            dy = y123 - (y1 + y3) / 2
            if dx*dx + dy*dy <= m_distance_tolerance:
                self.point(x123, y123, attr, row)
                return

        # Continue subdivision
        self._recursive_bezier(x1, y1, x12, y12, x123, y123, attr, row, level + 1)
        self._recursive_bezier(x123, y123, x23, y23, x3, y3, attr, row, level + 1)
659982
def length(self):
        
        return math.sqrt(
            (self.endpoint_a.northing - self.endpoint_b.northing) ** 2 +
            (self.endpoint_a.easting - self.endpoint_b.easting) ** 2
        )
14916
def _make_S_curve(x, range=(-0.75, 0.75)):
    """"""
    assert x.ndim == 1
    x = x - x.min()
    theta = 2 * np.pi * (range[0] + (range[1] - range[0]) * x / x.max())
    X = np.empty((x.shape[0], 2), dtype=float)
    X[:, 0] = np.sign(theta) * (1 - np.cos(theta))
    X[:, 1] = np.sin(theta)
    X *= x.max() / (2 * np.pi * (range[1] - range[0]))
    return X
349564
function getGridDimension(diff, step) {

        // return step if diff = 0
        if (!diff) return step;

        var absDiff = Math.abs(diff);
        var numSteps = Math.round(absDiff / step);

        // return absDiff if less than one step apart
        if (!numSteps) return absDiff;

        // otherwise, return corrected step
        var roundedDiff = numSteps * step;
        var remainder = absDiff - roundedDiff;
        var stepCorrection = remainder / numSteps;

        return step + stepCorrection;
    }
382728
def stdev(self):
        
        return round(np.std(self.array), self.precision)\
            if len(self.array) else None
582633
def precision
      @precision ||= cells.map(&:to_f).map { |n| n.round(3) }.map { |n| n.to_s.split(".").last.gsub(/0+$/, "").length }.max
    end
350525
def get_flat(self):
        
        self._check_sess()
        return np.concatenate([
            v.eval(session=self.sess).flatten()
            for v in self.variables.values()
        ])
942771
public static double length3D(CoordinateSequence pts) {
                // optimized for processing CoordinateSequences
                int n = pts.size();
                if (n <= 1) {
                        return 0.0;
                }

                double len = 0.0;

                Coordinate p = new Coordinate();
                pts.getCoordinate(0, p);
                double x0 = p.x;
                double y0 = p.y;
                double z0 = p.z;

                if (Double.isNaN(z0)) {
                        return 0.0;
                }

                for (int i = 1; i < n; i++) {
                        pts.getCoordinate(i, p);

                        double x1 = p.x;
                        double y1 = p.y;
                        double z1 = p.z;
                        if (Double.isNaN(z1)) {
                                return 0.0;
                        }
                        double dx = x1 - x0;
                        double dy = y1 - y0;
                        double dz = z1 - z0;

                        len += Math.sqrt(dx * dx + dy * dy + dz * dz);
                        x0 = x1;
                        y0 = y1;
                        z0 = z1;
                }
                return len;
        }
823427
function getFixedScrollOffset(offset, length) {
        if (offset && length + offset <= limit) {
          return Math.min(limit - length, 0);
        }
        return Math.min(offset, 0);
      }