package graphics; public class Torus extends Shape { private double innerRadius, outerRadius; public Torus(double ir, double or) { super(25, 25); innerRadius = ir; outerRadius = or; } public Torus(double ir, double or, int newM, int newN) { super(newM, newN); innerRadius = ir; outerRadius = or; } //convert u/v pair to xyz point protected double[] calculatePoint(double u, double v) { //System.err.println("calculatePoint("+u+", "+v+")"); //point-normal pair double[] vertex = {0,0,0, 0,0,0, 0,0}; double theta = 2 * Math.PI * u; double phi = 2 * Math.PI * v; //x = (a + b * cos θ) * cos φ //y = (a + b * sin θ) * cos φ //z = b sin φ vertex[0] = (outerRadius + innerRadius * Math.cos(theta)) * Math.sin(phi); //x vertex[1] = (outerRadius + innerRadius * Math.cos(theta)) * Math.cos(phi); //y vertex[2] = innerRadius * Math.sin(theta); //z //ignore normal for now vertex[6] = u; vertex[7] = v; return vertex; } //gotta overwrite this b/c of casting issues :-/ public Object clone() { Torus newTorus = new Torus(M, N); for (int i=0; i