summaryrefslogtreecommitdiff
path: root/thirdparty/thekla_atlas/nvmath/Sphere.h
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/thekla_atlas/nvmath/Sphere.h')
-rw-r--r--thirdparty/thekla_atlas/nvmath/Sphere.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/thirdparty/thekla_atlas/nvmath/Sphere.h b/thirdparty/thekla_atlas/nvmath/Sphere.h
new file mode 100644
index 0000000000..300731af44
--- /dev/null
+++ b/thirdparty/thekla_atlas/nvmath/Sphere.h
@@ -0,0 +1,43 @@
+// This code is in the public domain -- Ignacio Castaņo <castano@gmail.com>
+
+#pragma once
+#ifndef NV_MATH_SPHERE_H
+#define NV_MATH_SPHERE_H
+
+#include "Vector.h"
+
+namespace nv
+{
+
+ class Sphere
+ {
+ public:
+ Sphere() {}
+ Sphere(Vector3::Arg center, float radius) : center(center), radius(radius) {}
+
+ Sphere(Vector3::Arg center) : center(center), radius(0.0f) {}
+ Sphere(Vector3::Arg p0, Vector3::Arg p1);
+ Sphere(Vector3::Arg p0, Vector3::Arg p1, Vector3::Arg p2);
+ Sphere(Vector3::Arg p0, Vector3::Arg p1, Vector3::Arg p2, Vector3::Arg p3);
+
+ Vector3 center;
+ float radius;
+ };
+
+ // Returns negative values if point is inside.
+ float distanceSquared(const Sphere & sphere, const Vector3 &point);
+
+
+ // Welz's algorithm. Fairly slow, recursive implementation uses large stack.
+ Sphere miniBall(const Vector3 * pointArray, uint pointCount);
+
+ Sphere approximateSphere_Ritter(const Vector3 * pointArray, uint pointCount);
+ Sphere approximateSphere_AABB(const Vector3 * pointArray, uint pointCount);
+ Sphere approximateSphere_EPOS6(const Vector3 * pointArray, uint pointCount);
+ Sphere approximateSphere_EPOS14(const Vector3 * pointArray, uint pointCount);
+
+
+} // nv namespace
+
+
+#endif // NV_MATH_SPHERE_H