public class Tube extends Shape {
    final int NSLATS;
    public Tube(int nslats) {
        NSLATS = nslats;
        int facesizes[] = new int[NSLATS+2];
        for(int i=0; i<NSLATS; ++i) 
            facesizes[i] = 4;
        facesizes[NSLATS] = facesizes[NSLATS+1] = NSLATS;
        init(2*NSLATS,facesizes);
        for(int n = 0; n<NSLATS; ++n) {
            double th = 2*Math.PI*n/NSLATS,
                    x = Math.cos(th),
                    y = Math.sin(th);
            Vector3D outward = new Vector3D(x,y,0);
            vertices_[n]        = new Vertex(new Vector3D(x,y,-1),outward);
            vertices_[n+NSLATS] = new Vertex(new Vector3D(x,y,1),outward);
        }
        for(int n = 0; n<NSLATS; ++n) {
            faces_[n][0] = n;
            faces_[n][1] = (n+1)%NSLATS;
            faces_[n][2] = (n+1)%NSLATS+NSLATS;
            faces_[n][3] = n+NSLATS;
            //System.out.println("face " + face + " is " + faces_[face][0] + " " + faces_[face][1] + " " + faces_[face][2] + " " + faces_[face][3]);            
        }
        for(int i = 0; i<NSLATS; ++i) {
            // normals are incorrect but unused in RT
            faces_[NSLATS][i] = i+NSLATS;
            faces_[NSLATS+1][NSLATS-i-1] = i;
        }
    }
}
