Returns a polygon in this surface, the order is arbitrary.

@param n one based index
@return polygon at index
174076
public PolygonExpression<?> patchN(int n) {
        return GeometryExpressions.polygonOperation(SpatialOps.SURFACE, mixin, ConstantImpl.create(n));
    }
823285
public static double[] getEvenlySpacedRanks(final int n) {
    if (n <= 0) {
      throw new SketchesArgumentException("n must be > 0");
    }
    final double[] fractions = new double[n];
    fractions[0] = 0.0;
    for (int i = 1; i < n; i++) {
      fractions[i] = (double) i / (n - 1);
    }
    if (n > 1) {
      fractions[n - 1] = 1.0;
    }
    return fractions;
  }
711058
public function createVertices($n)
    {
        $vertices = array();
        if (is_int($n) && $n >= 0) {
            for ($id = $this->getNextId(), $n += $id; $id < $n; ++$id) {
                $vertices[$id] = new Vertex($this, $id);
            }
        } elseif (is_array($n)) {
            // array given => check to make sure all given IDs are available (atomic operation)
            foreach ($n as $id) {
                if (!is_int($id) && !is_string($id)) {
                    throw new InvalidArgumentException('All Vertex IDs have to be of type integer or string');
                } elseif ($this->vertices->hasVertexId($id)) {
                    throw new OverflowException('Given array of Vertex IDs contains an ID that already exists. Given IDs must be unique');
                } elseif (isset($vertices[$id])) {
                    throw new InvalidArgumentException('Given array of Vertex IDs contain duplicate IDs. Given IDs must be unique');
                }

                // temporary marker to check for duplicate IDs in the array
                $vertices[$id] = false;
            }

            // actually create all requested vertices
            foreach ($n as $id) {
                $vertices[$id] = new Vertex($this, $id);
            }
        } else {
            throw new InvalidArgumentException('Invalid number of vertices given. Must be non-negative integer or an array of Vertex IDs');
        }

        return new Vertices($vertices);
    }
315418
public static Polygon of(LinearRing perimeter, LinearRing... holes) {
        return Polygon.of(perimeter, Arrays.asList(holes));
    }
848700
private static Polygon processPolygon(Polygon p, Geometry triangleLines, GeometryFactory factory) {
        Geometry diffExt = p.getExteriorRing().difference(triangleLines);
        final int nbOfHoles = p.getNumInteriorRing();
        final LinearRing[] holes = new LinearRing[nbOfHoles];
        for (int i = 0; i < nbOfHoles; i++) {
            holes[i] = factory.createLinearRing(lineMerge(p.getInteriorRingN(i).difference(triangleLines), factory).getCoordinates());
        }
        return factory.createPolygon(factory.createLinearRing(lineMerge(diffExt, factory).getCoordinates()), holes);

    }
721248
public static Color[] getNColors(int n) {
    Color[] colors = new Color[n];
    if (n <= basicColors.length) {
      System.arraycopy(basicColors, 0, colors, 0, n);
    } else {
      int s = 255 / (int)Math.ceil(Math.pow(n, (1.0 / 3.0)));
      int index = 0;
      OUTER: for (int i = 0; i < 256; i += s) {
        for (int j = 0; j < 256; j += s) {
          for (int k = 0; k < 256; k += s) {
            colors[index++] = new Color(i,j,k);
            if (index == n) { break OUTER; }
          }
        }
      }
    }
    return colors;
  }
211918
public List<Polygon> polygons() {
        return positions().children().stream()
                .map(Polygon::new)
                .collect(Collectors.toList());

    }
834401
public LinearRing getInteriorRingN(int n) {
		if (!isEmpty()) {
			if (interiorRings != null && interiorRings.length > n) {
				return interiorRings[n];
			}
		}
		return null;
	}
1256549
private static Geometry shadowPolygon(Polygon polygon, double[] shadowOffset, GeometryFactory factory, boolean doUnion) {
        Coordinate[] shellCoords = polygon.getExteriorRing().getCoordinates();
        Collection<Polygon> shadows = new ArrayList<Polygon>();
        createShadowPolygons(shadows, shellCoords, shadowOffset, factory);
        final int nbOfHoles = polygon.getNumInteriorRing();
        for (int i = 0; i < nbOfHoles; i++) {
            createShadowPolygons(shadows, polygon.getInteriorRingN(i).getCoordinates(), shadowOffset, factory);
        }
        if (!doUnion) {
            return factory.buildGeometry(shadows);
        } else {
            if (!shadows.isEmpty()) {
                Collection<Geometry> shadowParts = new ArrayList<Geometry>();
                for (Polygon shadowPolygon : shadows) {
                    shadowParts.add(shadowPolygon.difference(polygon));
                }
                Geometry allShadowParts = factory.buildGeometry(shadowParts);
                Geometry union = allShadowParts.buffer(0);
                union.apply(new UpdateZCoordinateSequenceFilter(0, 1));
                return union;
            }
            return null;
        }
        
    }
1187003
public Polygon toPolygon(com.google.android.gms.maps.model.Polygon polygon,
                             boolean hasZ, boolean hasM) {
        return toPolygon(polygon.getPoints(), polygon.getHoles(), hasZ, hasM);
    }
1052716
public Shape prune() {
    	Polygon result = new Polygon();
    	
    	for (int i=0;i<getPointCount();i++) {
    		int next = i+1 >= getPointCount() ? 0 : i+1;
    		int prev = i-1 < 0 ? getPointCount() - 1 : i-1;
    		
    		float dx1 = getPoint(i)[0] - getPoint(prev)[0];
    		float dy1 = getPoint(i)[1] - getPoint(prev)[1];
    		float dx2 = getPoint(next)[0] - getPoint(i)[0];
    		float dy2 = getPoint(next)[1] - getPoint(i)[1];
    		
    		float len1 = (float) Math.sqrt((dx1*dx1) + (dy1*dy1));
    		float len2 = (float) Math.sqrt((dx2*dx2) + (dy2*dy2));
    		dx1 /= len1;
    		dy1 /= len1;
    		dx2 /= len2;
    		dy2 /= len2;
    		
    		if ((dx1 != dx2) || (dy1 != dy2)) {
    			result.addPoint(getPoint(i)[0],getPoint(i)[1]);
    		}
    	}
    	
    	return result;
    }
109295
public Object productElement(int n) {
        assert n >= 0 && n < 3;
        switch (n) {
            case 0: return dataType;
            case 1: return geographicalLocation;
            case 2: return isSecret;
            default: throw new IllegalArgumentException(n + " is not an allowed index into UserStub!");
        }
    }
136252
public Polygon getHull() {
    if(hull == null) {
      run(true);
    }
    DoubleMinMax minmaxX = new DoubleMinMax();
    DoubleMinMax minmaxY = new DoubleMinMax();
    List<double[]> hullp = new ArrayList<>(hull.size());
    for(IntIntPair pair : hull) {
      double[] v = points.get(pair.first);
      hullp.add(v);
      minmaxX.put(v[0]);
      minmaxY.put(v[1]);
    }
    return new Polygon(hullp, minmaxX.getMin(), minmaxX.getMax(), minmaxY.getMin(), minmaxY.getMax());
  }
157422
public static Matrix identity(int N) {
        Matrix I = new Matrix(N, N);
        for (int i = 0; i < N; i++) {
            I.data[i][i] = 1;
        }
        return I;
    }
668198
protected double trapezoid( int n ) {
        double x = 0;
        double tnm = 0;
        double sum = 0;
        double del = 0;
        int it = 0;
        int j = 0;

        if (n == 1) {
            strapezoid = 0.5f * (upperlimit - lowerlimit)
                    * (equation(lowerlimit) + equation(upperlimit));
        } else {
            /*
             * for (it = 1, j = 1; j < n - 1; j++) { it <<= 1; }
             */
            it = (int) Math.pow(2.0, n - 1);

            tnm = (double) it;
            del = (upperlimit - lowerlimit) / tnm;
            x = lowerlimit + 0.5f * del;
            for( sum = 0f, j = 1; j <= it; j++, x += del ) {
                if (x >= upperlimit) {
                    System.out.println("hoi");
                }
                sum += equation(x);
            }
            strapezoid = (double) (0.5f * (strapezoid + (upperlimit - lowerlimit) * sum / tnm));
        }

        return strapezoid;
    }
496148
public List<T> pollN(int n) {
    if (n >= size) {
      return pollAll();
    }
    List<T> retList = new ArrayList<T>(n);
    if (n == 0) {
      return retList;
    }
    boolean done = false;
    int currentBucketIndex = 0;

    while (!done) {
      LinkedElement<T> current = entries[currentBucketIndex];
      while (current != null) {
        retList.add(current.element);
        current = current.next;
        entries[currentBucketIndex] = current;
        size--;
        modification++;
        if (--n == 0) {
          done = true;
          break;
        }
      }
      currentBucketIndex++;
    }
    shrinkIfNecessary();
    return retList;
  }
77942
public static Integer getHoles(Geometry g) {
        if(g == null) {
            return null;
        }
        if (g instanceof MultiPolygon) {            
            Polygon p = (Polygon) g.getGeometryN(0);
            if(p!=null){
                return p.getNumInteriorRing();
            }            
        } else if (g instanceof Polygon) {
            return ((Polygon) g).getNumInteriorRing();
        }
        return null;
    }