10 #ifndef INCLUDED_IMATHSPHERE_H
11 #define INCLUDED_IMATHSPHERE_H
20 IMATH_INTERNAL_NAMESPACE_HEADER_ENTER
100 center =
T (0.5) * (box.min + box.max);
108 bool doesIntersect =
true;
111 T B =
T (2.0) * (line.
dir ^
v);
112 T C = (v ^
v) - (radius * radius);
117 T discr = B * B -
T (4.0) * C;
123 doesIntersect =
false;
130 t = (-B - sqroot) *
T (0.5);
136 t = (-B + sqroot) *
T (0.5);
140 doesIntersect =
false;
143 return doesIntersect;
147 IMATH_CONSTEXPR14
bool
152 if (intersectT (line, t))
154 intersection = line (t);
163 IMATH_INTERNAL_NAMESPACE_HEADER_EXIT
165 #endif // INCLUDED_IMATHSPHERE_H
Vec3< T > pos
A point on the line.
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool intersectT(const Line3< T > &l, T &t) const
IMATH_HOSTDEVICE constexpr Sphere3(const Vec3< T > &c, T r)
Initialize to a given center and radius.
vfloat4 sqrt(const vfloat4 &a)
GLuint GLsizei GLsizei * length
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool intersect(const Line3< T > &l, Vec3< T > &intersection) const
IMATH_HOSTDEVICE constexpr Sphere3()
Default is center at (0,0,0) and radius of 0.
Vec3< T > dir
The direction of the line.
#define IMATH_EXPORT_TEMPLATE_TYPE
IMATH_CONSTEXPR14 bool intersect(const Line3< T > &line, const Vec3< T > &v0, const Vec3< T > &v1, const Vec3< T > &v2, Vec3< T > &pt, Vec3< T > &barycentric, bool &front) IMATH_NOEXCEPT
Sphere3< float > Sphere3f
Sphere of type float.
IMATH_HOSTDEVICE void circumscribe(const Box< Vec3< T >> &box)
Sphere3< double > Sphere3d
Sphere of type double.