10 #ifndef INCLUDED_IMATHSPHERE_H
11 #define INCLUDED_IMATHSPHERE_H
20 IMATH_INTERNAL_NAMESPACE_HEADER_ENTER
48 : center (c), radius (r)
102 center =
T (0.5) * (box.min + box.max);
103 radius = (box.max - center).
length ();
110 bool doesIntersect =
true;
113 T B =
T (2.0) * (line.
dir ^
v);
114 T C = (v ^
v) - (radius * radius);
119 T discr = B * B -
T (4.0) * C;
125 doesIntersect =
false;
132 t = (-B - sqroot) *
T (0.5);
138 t = (-B + sqroot) *
T (0.5);
141 if (t < 0.0) doesIntersect =
false;
144 return doesIntersect;
148 IMATH_CONSTEXPR14
bool
153 if (intersectT (line, t))
155 intersection = line (t);
164 IMATH_INTERNAL_NAMESPACE_HEADER_EXIT
166 #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.