charles/src/objectSphere.hh

41 lines
816 B
C++
Raw Normal View History

2013-09-10 09:34:15 -07:00
/* object_sphere.h
*
* Spheres are Shapes defined by a center point and a radius.
*
* Eryn Wells <eryn@erynwells.me>
*/
#ifndef __OBJECTSPHERE_HH__
#define __OBJECTSPHERE_HH__
2013-09-10 09:34:15 -07:00
#include "basics.h"
#include "object.h"
#include "basics/basics.hh"
2013-09-10 09:34:15 -07:00
namespace charles {
2013-09-10 09:34:15 -07:00
class Sphere
: public Object
2013-09-10 09:34:15 -07:00
{
public:
Sphere(const basics::Vector4& origin = basics::Vector4(), Double radius = 1.0);
2013-09-10 09:34:15 -07:00
Double GetRadius() const;
void SetRadius(Double r);
2013-09-10 09:34:15 -07:00
bool DoesIntersect(const Ray& ray, TVector& t, Stats& stats) const;
bool point_is_on_surface(const Vector3 &p) const;
Vector3 compute_normal(const Vector3 &p) const;
/** @see charles::Object::Write */
void Write(std::ostream& ost) const;
2013-09-10 09:34:15 -07:00
private:
Double mRadius;
2013-09-10 09:34:15 -07:00
};
} /* namespace charles */
#endif /* __OBJECTSPHERE_HH__ */