text: #ifndef SPHEREH
  #define SPHEREH
  
  #include "Hitable.h"
  
  class Sphere : public Hitable {
  public:
  	Sphere() {}
  	Sphere(Vec3 cen, float r, Material* matPtrIn) : center(cen), radius(r), matPtr(matPtrIn) {};
  	virtual bool hit(const Ray& r, float tMin, float tMax, HitRecord& rec) const;
  
  	Vec3 center;
  	float radius;
  	Material* matPtr;
  };
  
  bool Sphere::hit(const Ray& r, float tMin, float tMax, HitRecord& rec) const {
  	Vec3 oc = r.origin() - center;
  	float a = dot(r.direction(), r.direction());
  	float b = dot(oc, r.direction());
  	float c = dot(oc, oc) - radius * radius;
  	float discriminant = b * b - a * c;
  
  	if (discriminant > 0) {
  		float temp = (-b - sqrt(b * b - a * c)) / a;
  		if (temp < tMax && temp > tMin) {
  			rec.t = temp;
  			rec.p = r.pointAtParameter(rec.t);
  			rec.normal = (rec.p - center) / radius;
  			rec.matPtr = matPtr;
  			return true;
  		}
  		temp = (-b + sqrt(b * b - a * c)) / a;
  		if (temp < tMax && temp > tMin) {
  			rec.t = temp;
  			rec.p = r.pointAtParameter(rec.t);
  			rec.normal = (rec.p - center) / radius;
  			rec.matPtr = matPtr;
  			return true;
  		}
  	}
  	return false;
  }
  
  #endif // !SPHEREH
  