private boolean isCCW(GeoPoint a, GeoPoint b, GeoPoint c) {
   Point i = a.toPoint(1.0);
   Point j = b.toPoint(1.0);
   Point k = c.toPoint(1.0);
   Vector cross = Vector.cross(i, j, k).normalize();
   Point l = i.translate(cross);
   double d = Vector.computeDistance(l.x, l.y, l.z);
   return d < 1.0;
 }
示例#2
0
  private static Point[] genVertices() {
    Point[] vertices = {
      new Point(0, -0.4, 0),
      new Point(-0.52, -0.4, 0.165),
      new Point(-0.4, -0.4, 0.4),
      new Point(-0.2, -0.4, 0.3),
      new Point(0, -0.4, 0.22),
      new Point(-0.94, -0.225, 0.3), // 6
      new Point(-0.86, -0.225, 0.91),
      new Point(-0.2, -0.225, 0.8),
      new Point(0, -0.225, 0.4),
      new Point(-0.94, 0, 0.3), // 10
      new Point(-0.86, 0, 0.91),
      new Point(-0.2, 0, 0.8),
      new Point(0, 0, 0.4),
      new Point(0, -0.4, -0.22), // 14
      new Point(-0.2, -0.3, -0.6),
      new Point(-0.4, -0.4, -0.2),
      new Point(0, -0.2, -0.8), // 17
      new Point(-0.6, -0.2, -0.6),
      new Point(-0.99, -0.225, -0.06),
      new Point(0, 0, -1), // 20
      new Point(-0.6, 0, -0.6),
      new Point(-0.99, 0, -0.06)
    };

    int length = vertices.length;
    List<Point> allpoints = new ArrayList<Point>(length);
    for (int scaleX = 1; scaleX > -2; scaleX -= 2) {
      for (int scaleY = 1; scaleY > -2; scaleY -= 2) {
        boolean includeZeroY = scaleX == scaleY && scaleX == 1;
        for (Point vertex : vertices) {
          Point p = vertex.scale(new Vector(scaleX, scaleY, 1.0));
          if (includeZeroY || p.y != 0) {
            allpoints.add(p);
          }
        }
      }
    }
    return allpoints.toArray(new Point[allpoints.size()]);
  }