public double collision(Ray ray){
		//setting up values for quad formula
		double t0;
		double t1;
		double t = Double.MAX_VALUE;
		Vector3D oMinC = (ray.getOrigin().subtract(position));
		double a = Vector3D.dotProduct(ray.getDirection(),ray.getDirection());
		double b = 2*Vector3D.dotProduct(oMinC,ray.getDirection());
		double c = Vector3D.dotProduct(oMinC,oMinC) - radius*radius;
		double discriminant = b*b -4*a*c;
		if (discriminant >= 0){//there is an intercept
			t0 = -b-Math.sqrt(discriminant);
			t1 = -b+Math.sqrt(discriminant);
			t0 = t0/(2*a);
			t1 = t1/(2*a);
			//take the smallest non-negative t
			t = t0;
			if(t <0) t=t1;
			if(t < 0){
				t = Double.MAX_VALUE;
			}
		}
		return t;
	}