/*
获取由两个以上的点组成的曲线的平移线
@param points 曲线上的点的集合， 集合中的点的数量必须大于2
@return 平移线数组
167194
function(points, smoothFactor) {

                //计算原始点的中点坐标
                var centerPoints = CurveUtil.getCenterPoints(points),

                    //注意：计算中点连线的中点坐标， 得出平移线
                    panLines = CurveUtil.getPanLine(points.length, centerPoints);


                //平移线移动到顶点
                return CurveUtil.getMovedPanLines(points, panLines, smoothFactor);
            }
152677
function(points, angle) {
    var result = [];
    for(var i=0;i<points.length;i+=2) {
      var x = points[i + 0] * this._size;
      var y = points[i + 1] * this._size;
      var pt = this._rotate([x, y], angle);
      result.push(pt[0]);
      result.push(pt[1]);
    }
    return result;
  }
538379
protected void createPoints() {
        ArrayList tempPoints = new ArrayList();

        maxX = -Float.MIN_VALUE;
        maxY = -Float.MIN_VALUE;
        minX = Float.MAX_VALUE;
        minY = Float.MAX_VALUE;

        float start = 0;
        float end = 359;
        
        float cx = x + radius1;
        float cy = y + radius2;
        
        int step = 360 / segmentCount;
        
        for (float a=start;a<=end+step;a+=step) {
            float ang = a;
            if (ang > end) {
                ang = end;
            }
            float newX = (float) (cx + (FastTrig.cos(Math.toRadians(ang)) * radius1));
            float newY = (float) (cy + (FastTrig.sin(Math.toRadians(ang)) * radius2));

            if(newX > maxX) {
                maxX = newX;
            }
            if(newY > maxY) {
                maxY = newY;
            }
            if(newX < minX) {
            	minX = newX;
            }
            if(newY < minY) {
            	minY = newY;
            }
            
            tempPoints.add(new Float(newX));
            tempPoints.add(new Float(newY));
        }
        points = new float[tempPoints.size()];
        for(int i=0;i<points.length;i++) {
            points[i] = ((Float)tempPoints.get(i)).floatValue();
        }
    }
1349121
public Point3d[] getVertices() {
        Point3d[] vtxs = new Point3d[numVertices];
        for (int i = 0; i < numVertices; i++) {
            vtxs[i] = pointBuffer[vertexPointIndices[i]].pnt;
        }
        return vtxs;
    }
395446
static String encodeCoordinates(Point2d[] points) {
        StringBuilder sb = new StringBuilder();
        sb.append("|(");
        for (Point2d point : points) {
            if (sb.length() > 2) sb.append(";");
            sb.append(DECIMAL_FORMAT.format(point.x));
            sb.append(',');
            sb.append(DECIMAL_FORMAT.format(point.y));
            sb.append(',');
        }
        sb.append(")|");
        return sb.toString();
    }
534059
public List<Point> points() {
        return positions().children().stream()
                .map(Point::new)
                .collect(Collectors.toList());

    }
1194574
public List<Cluster> cluster(final Collection<Point2D> points) {
    	final List<Cluster> clusters = new ArrayList<Cluster>();
        final Map<Point2D, PointStatus> visited = new HashMap<Point2D, DBScan.PointStatus>();

        KDTree<Point2D> tree = new KDTree<Point2D>(2);
        
        // Populate the kdTree
        for (final Point2D point : points) {
        	double[] key = {point.x, point.y};
        	tree.insert(key, point);
        }
                
        for (final Point2D point : points) {
            if (visited.get(point) != null) {
                continue;
            }
            final List<Point2D> neighbors = getNeighbors(point, tree);
            if (neighbors.size() >= minPoints) {
                // DBSCAN does not care about center points
                final Cluster cluster = new Cluster(clusters.size());
                clusters.add(expandCluster(cluster, point, neighbors, tree, visited));
            } else {
                visited.put(point, PointStatus.NOISE);
            }
        }

        for (Cluster cluster : clusters) {
        	cluster.calculateCentroid();
        }
        
        return clusters;
    }
611302
function parsePoints(points) {
    var coord = this._coord;
    var rst = [];
    Util.each(points, function (point) {
      rst.push(coord.convertPoint(point));
    });
    return rst;
  }
790020
protected List<mxPoint> optimizeEdgePoints(List<mxPoint> unoptimizedPointsList) {
    List<mxPoint> optimizedPointsList = new ArrayList<mxPoint>();
    for (int i = 0; i < unoptimizedPointsList.size(); i++) {

      boolean keepPoint = true;
      mxPoint currentPoint = unoptimizedPointsList.get(i);

      // When three points are on the same x-axis with same y value, the
      // middle point can be removed
      if (i > 0 && i != unoptimizedPointsList.size() - 1) {

        mxPoint previousPoint = unoptimizedPointsList.get(i - 1);
        mxPoint nextPoint = unoptimizedPointsList.get(i + 1);

        if (currentPoint.getX() >= previousPoint.getX() && currentPoint.getX() <= nextPoint.getX() && currentPoint.getY() == previousPoint.getY() && currentPoint.getY() == nextPoint.getY()) {
          keepPoint = false;
        } else if (currentPoint.getY() >= previousPoint.getY() && currentPoint.getY() <= nextPoint.getY() && currentPoint.getX() == previousPoint.getX() && currentPoint.getX() == nextPoint.getX()) {
          keepPoint = false;
        }

      }

      if (keepPoint) {
        optimizedPointsList.add(currentPoint);
      }

    }

    return optimizedPointsList;
  }
369530
public Point<Object> getValues(Point<Integer> locations) {
    Point<Object>	result;
    Object[]		values;
    int		i;

    if (locations.dimensions() != dimensions())
      throw new IllegalArgumentException(
        "Dimension mismatch: space=" + dimensions()
          + ", locations=" + locations.dimensions());

    values = new Object[locations.dimensions()];
    for (i = 0; i < values.length; i++)
      values[i] = getDimension(i).getValue(locations.getValue(i));

    result = new Point<Object>(values);

    return result;
  }
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;
    }
252592
public static double[] computeDxs(List<KmeansPoint> basePoints, List<KmeansPoint> centroids)
    {
        double[] dxs = new double[basePoints.size()];

        double sum = 0.0d;
        double[] nearestCentroid;
        for (int pointIndex = 0; pointIndex < basePoints.size(); pointIndex++)
        {
            // 対象点に対する最近傍中心との距離(dx)を算出し、二乗に比例する重み付き確率分布値を算出
            KmeansPoint targetPoint = basePoints.get(pointIndex);
            KmeansResult kmeanResult = KmeansCalculator.nearestCentroid(targetPoint, centroids);
            nearestCentroid = kmeanResult.getCentroid();
            double dx = MathUtils.distance(targetPoint.getDataPoint(), nearestCentroid);
            double probabilityDist = Math.pow(dx, 2);
            sum += probabilityDist;
            dxs[pointIndex] = sum;
        }

        return dxs;
    }
810095
public boolean isOnBorder(Point<?> points) {
    boolean		result;
    Point<Integer>	locations;
    int		i;

    if (points.dimensions() != dimensions())
      throw new IllegalArgumentException(
        "Dimension mismatch: space=" + dimensions()
          + ", points=" + points.dimensions());

    if (!(points.getValue(0) instanceof Integer))
      locations = getLocations((Point<Object>) points);
    else
      locations = (Point<Integer>) points;

    result = false;
    for (i = 0; i < dimensions(); i++) {
      if (getDimension(i).isOnBorder(locations.getValue(i))) {
        result = true;
        break;
      }
    }

    return result;
  }
1293851
public double calcKMeansCosts(double[] center, double[] point) {
		assert (this.sumPoints.length == center.length &&
				this.sumPoints.length == point.length);
		return (this.sumSquaredLength + Metric.distanceSquared(point)) - 2
				* Metric.dotProductWithAddition(this.sumPoints, point, center)
				+ (this.numPoints + 1) * Metric.dotProduct(center);
	}
1284370
private List<Point> simplifyPoints(List<Point> points) {

        List<Point> simplifiedPoints = null;
        if (simplifyTolerance != null) {

            // Reproject to web mercator if not in meters
            if (projection != null && !projection.isUnit(Units.METRES)) {
                points = toWebMercator.transform(points);
            }

            // Simplify the points
            simplifiedPoints = GeometryUtils.simplifyPoints(points,
                    simplifyTolerance);

            // Reproject back to the original projection
            if (projection != null && !projection.isUnit(Units.METRES)) {
                simplifiedPoints = fromWebMercator.transform(simplifiedPoints);
            }
        } else {
            simplifiedPoints = points;
        }

        return simplifiedPoints;
    }
71641
public PointList calcPoints() {
        final PointList points = new PointList(edgeIds.size() + 1, nodeAccess.is3D());
        if (edgeIds.isEmpty()) {
            if (isFound()) {
                points.add(graph.getNodeAccess(), endNode);
            }
            return points;
        }

        int tmpNode = getFromNode();
        points.add(nodeAccess, tmpNode);
        forEveryEdge(new EdgeVisitor() {
            @Override
            public void next(EdgeIteratorState eb, int index, int prevEdgeId) {
                PointList pl = eb.fetchWayGeometry(2);
                for (int j = 0; j < pl.getSize(); j++) {
                    points.add(pl, j);
                }
            }

            @Override
            public void finish() {

            }
        });
        return points;
    }
720853
protected Vector<Point<Integer>> listPoints() {
    Vector<Point<Integer>>	result;
    int			i;
    int[]			max;
    Integer[]			locations;
    boolean			ok;

    result = new Vector<Point<Integer>>();

    // determine maximum locations per dimension
    max = new int[dimensions()];
    for (i = 0; i < max.length; i++)
      max[i] = getDimension(i).width();

    // create first point
    locations = new Integer[dimensions()];
    for (i = 0; i < locations.length; i++)
      locations[i] = 0;
    result.add(new Point<Integer>(locations));

    ok = true;
    while (ok) {
      ok = inc(locations, max);
      if (ok)
        result.add(new Point<Integer>(locations));
    }

    return result;
  }