import java.awt.*;
import java.util.*;
import java.lang.Math;

public class ParamCylinder extends ParamSurface //Sphere is the subclass
{
	double dTheta = 0, dPhi = 0;
	double dRadius;
	double dEpsilon;
	double dCenter[] = new double[4];
	double Cylinder3D[][];
	boolean bWasDrawn = false;
	
	public ParamCylinder()
	{
	}
	
	public ParamCylinder(double cx, double cy, double cz, double r, double epsilon)
	{
		super();
		dRadius = r;
		dEpsilon = epsilon;
		
		dCenter[0] = cx;
		dCenter[1] = cy;
		dCenter[2] = cz;
		dCenter[3] = 1;

		
		Cylinder3D = new double[400][4];
		
		int i = 0;
		for (double v = 0; v < 1; v += dEpsilon)
		{
			for (double u = 0; u < 1; u += dEpsilon)
			{
				Cylinder3D[i][0] = x(u,v)+cx;
				Cylinder3D[i][1] = y(u,v)+cy;
				Cylinder3D[i][2] = z(u,v)+cz;
				Cylinder3D[i][3] = 1;
				i++;
			}
		}
	}

	public double x(double u, double v)
	{
		return dRadius*Math.cos(u*Math.PI*2);
	}	

	public double y(double u, double v)
	{
		return dRadius*Math.sin(u*Math.PI*2);
	}	

	public double z(double u, double v)
	{
		return v;
	}
	
	public void setShape(double newSphere[][])
	{
		int len = newSphere.length;
		for (int i=0; i<len; i++)
			Cylinder3D[i] = newSphere[i];
	}
	
	public double[][] getShape()
	{
		return Cylinder3D;
	}
	
	public double[] getCenter()
	{
		return dCenter;
	}
	
	public double getRadius()
	{
		return dRadius;
	}
	
	public void setCenter(double newCenter[])
	{
		for (int i=0; i<4; i++)
			dCenter[i] = newCenter[i];
	}
	
	public boolean wasDrawn()
	{
		return bWasDrawn;
	}
	
	public void setDraw(boolean drawState)
	{
		bWasDrawn = drawState;
	}
}
