static float getPerimeter(Polygon p) {
		if (p == null)
			throw new NullPointerException("p cannot be null");
		double perimeter = 0.0;
		int dx, dy;
		int n1 = p.npoints - 1;
		for (int i = 0; i < n1; i++) {
			dx = p.xpoints[i] - p.xpoints[i + 1];
			dy = p.ypoints[i] - p.ypoints[i + 1];
			perimeter += Math.hypot(dx, dy);
		}
		dx = p.xpoints[n1] - p.xpoints[0];
		dy = p.ypoints[n1] - p.ypoints[0];
		perimeter += Math.hypot(dx, dy);
		return (float) perimeter;
	}