paysages3d/src/basics/Sphere.h

52 lines
1.1 KiB
C
Raw Normal View History

2015-10-15 18:21:32 +00:00
#ifndef SPHERE_H
#define SPHERE_H
#include "basics_global.h"
#include "Vector3.h"
namespace paysages {
namespace basics {
/**
* Geometric sphere.
*/
class BASICSSHARED_EXPORT Sphere {
public:
Sphere() = default;
2015-10-15 18:21:32 +00:00
Sphere(const Vector3 &center, double radius);
inline const Vector3 &getCenter() const {
return center;
}
inline const double &getRadius() const {
return radius;
}
2015-10-15 18:21:32 +00:00
/**
* Check for intersections between the sphere and an infinite ray.
*
* Returns the number of intersections (0, 1 or 2).
*/
int checkRayIntersection(const InfiniteRay &ray) const;
/**
* Get the intersections between the sphere and an infinite ray.
2015-10-15 18:21:32 +00:00
*
* Returns the number of intersections (0, 1 or 2) and fill the intersection points.
*/
int findRayIntersection(const InfiniteRay &ray, Vector3 *first_intersection, Vector3 *second_intersection) const;
2015-10-15 18:21:32 +00:00
void save(PackStream *stream) const;
void load(PackStream *stream);
private:
2015-10-15 18:21:32 +00:00
Vector3 center;
double radius;
double radius2;
};
}
}
#endif // SPHERE_H