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/BoundingVolumeSphere3.h
FrankE 686151b511 worked on 2D/3D raytracing
adjusted BVH
improved 2D/3D BVH
new bounding volumes
new test cases
renamed some test-cases for grouping reasons
made GPC header-only using slight adjustments
2017-09-13 08:08:00 +02:00

54 lines
1.4 KiB
C++

#ifndef BOUNDINGVOLUMESPHERE_H
#define BOUNDINGVOLUMESPHERE_H
#include "BoundingVolume.h"
#include "../Sphere3.h"
#include "../Point3.h"
class BoundingVolumeSphere3 : public BoundingVolume, public Sphere3 {
public:
BoundingVolumeSphere3() {;}
BoundingVolumeSphere3(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 BoundingVolumeSphere3& sphere = (const BoundingVolumeSphere3&) other;
return Sphere3::intersects(sphere);
}
/** does the volume contain the given volume? */
bool contains(const BoundingVolume& other) const {
const BoundingVolumeSphere3& sphere = (const BoundingVolumeSphere3&) other;
return Sphere3::contains(sphere);
}
/** construct a volume around the given point-set */
static BoundingVolumeSphere3 fromVertices(const std::vector<Point3>& verts) {
BoundingVolumeSphere3 bvs;
bvs.adjustToPointSet(verts);
return bvs;
}
static BoundingVolumeSphere3 join(const BoundingVolumeSphere3 a, const BoundingVolumeSphere3 b) {
return BoundingVolumeSphere3(Sphere3::join(a, b));
}
};
#endif // BOUNDINGVOLUMESPHERE_H