64 lines
1.7 KiB
C++
64 lines
1.7 KiB
C++
/*
|
||
* © Copyright 2014 – Urheberrechtshinweis
|
||
* Alle Rechte vorbehalten / All Rights Reserved
|
||
*
|
||
* Programmcode ist urheberrechtlich geschuetzt.
|
||
* Das Urheberrecht liegt, soweit nicht ausdruecklich anders gekennzeichnet, bei Frank Ebner.
|
||
* Keine Verwendung ohne explizite Genehmigung.
|
||
* (vgl. § 106 ff UrhG / § 97 UrhG)
|
||
*/
|
||
|
||
#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
|