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
This commit is contained in:
53
geo/volume/BoundingVolumeSphere3.h
Normal file
53
geo/volume/BoundingVolumeSphere3.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#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
|
||||
Reference in New Issue
Block a user