Sphere3¶
#include <Imath/ImathSphere.h>
The Sphere3 class template represents a sphere in 3D space, with
predefined typedefs for lines of type float and double.
Example:
#include <Imath/ImathSphere.h>
void
sphere3_example()
{
Imath::V3f center (1.0f, 1.0f, 1.0f);
float radius = 2.0f;
Imath::Sphere3f s (center, radius);
assert (s.center == center);
assert (s.radius == radius);
Imath::Line3f line (Imath::V3f (0.0f, 0.0f, 0.0f),
Imath::V3f (1.0f, 1.0f, 1.0f));
Imath::V3f v;
assert (s.intersect (line, v));
assert (v.equalWithAbsError (Imath::V3f(2.1547f, 2.1547f, 2.1547f), 1e-6f));
}
-
template<class
T>
classImath::Sphere3¶ A 3D sphere.
Constructors
-
inline constexpr
Sphere3()¶ Default is center at (0,0,0) and radius of 0.
Manipulation
Utility Methods
-
constexpr bool
intersect(const Line3<T> &l, Vec3<T> &intersection) const¶ If the sphere and line
lintersect, then compute the smallesttwitht>=0so thatl(t)is a point on the sphere.- Return
True if the sphere and line intersect, false if they do not.
- Parameters
[in] l: The line[out] intersection: The point of intersection
-
constexpr bool
intersectT(const Line3<T> &l, T &t) const¶ If the sphere and line
lintersect, then compute the smallesttwitht>=0so thatl(t)is a point on the sphere.- Return
True if the sphere and line intersect, false if they do not.
- Parameters
[in] l: The line[out] t: The parameter of the line at the intersection point
-
inline constexpr