This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Indoor/geo/volume/BoundingVolumeSphere.h
k-a-z-u c19d18a3a6 modified lib GPC for header only
worked on 3d traytracing
2017-09-06 17:04:19 +02:00

54 lines
1.4 KiB
C++

#ifndef BOUNDINGVOLUMESPHERE_H
#define BOUNDINGVOLUMESPHERE_H
#include "BoundingVolume.h"
#include "../Sphere3.h"
#include "../Point3.h"
class BoundingVolumeSphere : public BoundingVolume, public Sphere3 {
public:
BoundingVolumeSphere() {;}
BoundingVolumeSphere(const Sphere3& s) : Sphere3(s) {;}
float getVolumeSize() const {
return (4.0f / 3.0f) * M_PI * (radius*radius*radius);
}
bool contains(const Point3 p) const {
return Sphere3::contains(p);
}
bool intersects(const Ray3& ray) const {
return Sphere3::intersects(ray);
}
/** does the volume intersect with the given volume? */
bool intersects(const BoundingVolume& other) const {
const BoundingVolumeSphere& sphere = (const BoundingVolumeSphere&) other;
return Sphere3::intersects(sphere);
}
/** does the volume contain the given volume? */
bool contains(const BoundingVolume& other) const {
const BoundingVolumeSphere& sphere = (const BoundingVolumeSphere&) other;
return Sphere3::contains(sphere);
}
/** construct a volume around the given point-set */
static BoundingVolumeSphere fromVertices(const std::vector<Point3>& verts) {
BoundingVolumeSphere bvs;
bvs.adjustToPointSet(verts);
return bvs;
}
static BoundingVolumeSphere join(const BoundingVolumeSphere a, const BoundingVolumeSphere b) {
return BoundingVolumeSphere(Sphere3::join(a, b));
}
};
#endif // BOUNDINGVOLUMESPHERE_H