import java.util.*; import java.io.*; public class threedprinter_topraj { final static double EPS = 1e-7; final static int DEBUG = 0; Scanner sc; PrintStream ps; class Vertex { double x, y, z; public Vertex(double _x, double _y, double _z) { x = _x; y = _y; z = _z; } Vertex sub(Vertex a) { return new Vertex(x-a.x, y-a.y, z-a.z); } Vertex add(Vertex a) { return new Vertex(x+a.x, y+a.y, z+a.z); } Vertex div(double d) { return new Vertex(x/d, y/d, z/d); } Vertex mul(double d) { return new Vertex(x*d, y*d, z*d); } Vertex unit() { return div(mag()); } double mag() { return Math.sqrt(x*x + y*y + z*z); } public String toString() { return "(" + x + "," + y + "," + z + ")"; } } class Face { Vertex vertices[]; public Face(int _f) { vertices = new Vertex[_f]; } public String toString() { String str = ""; for(Vertex v:vertices) { str += v; } return str; } } //ab X ac Vertex cross(Vertex a, Vertex b, Vertex c) { return cross(b.sub(a), c.sub(a)); } //u X v Vertex cross(Vertex u, Vertex v) { double x = u.y*v.z - u.z*v.y; double y = u.z*v.x - u.x*v.z; double z = u.x*v.y - u.y*v.x; return new Vertex(x, y, z); } //u . v double dot(Vertex u, Vertex v) { return u.x*v.x + u.y*v.y + u.z*v.z; } boolean IsParallel(Vertex u, Vertex v) { Vertex cross = cross(u, v); return (cross.mag()0) { System.out.printf("volume of face = %.3f\n", volume); } return volume; } double ComputeVolume(Face faces[]) { double totalVolume = 0; Vertex centroid = GetCentroid(faces); for(Face face:faces) { totalVolume += GetFaceVolume(centroid, face); } return totalVolume; } public void doIt() throws Exception { sc = new Scanner( System.in ); ps = System.out; //new PrintStream( new FileOutputStream( "threedprinter.out" ) ); while(true) { int n = sc.nextInt(); if(n==0) break; double totalVolume = 0; for(int ni=0;ni0) { ps.printf("Face: %s\n", faces[fi]); } } //checks if(!AreCoplanarFaces(faces)) { System.out.printf("Faces are not coplanar\n"); System.exit(-1); } if(!IsConvex(faces)) { System.out.printf("Polyhedra is not coplanar\n"); } double volume = ComputeVolume(faces); totalVolume += volume; } ps.printf("%.2f\n", totalVolume); } } public static void main(String args[]) throws Exception { (new threedprinter_topraj()).doIt(); } }