37 #ifndef INCLUDED_IMATHSPHERE_H 38 #define INCLUDED_IMATHSPHERE_H 111 center = T(0.5) * (box.min + box.max);
112 radius = (box.max - center).length();
119 bool doesIntersect =
true;
122 T B = 2.0 * (line.
dir ^ v);
123 T C = (v ^ v) - (radius * radius);
128 T discr = B*B - 4.0*C;
134 doesIntersect =
false;
141 t = (-B - sqroot) * 0.5;
147 t = (-B + sqroot) * 0.5;
151 doesIntersect =
false;
154 return doesIntersect;
163 if (intersectT (line, t))
165 intersection = line(t);
Definition: ImathBox.h:71
Definition: ImathFrame.h:42
Definition: ImathSphere.h:53
T radius
Definition: ImathSphere.h:58
Vec3< T > center
Definition: ImathSphere.h:57
Vec3< T > dir
Definition: ImathLine.h:59
Vec3< T > pos
Definition: ImathLine.h:58
Sphere3(const Vec3< T > &c, T r)
Definition: ImathSphere.h:65
Definition: ImathLine.h:54
Sphere3< float > Sphere3f
Definition: ImathSphere.h:100
Sphere3()
Definition: ImathSphere.h:64
Sphere3< double > Sphere3d
Definition: ImathSphere.h:101
Definition: ImathBox.h:67
void circumscribe(const Box< Vec3< T > > &box)
Definition: ImathSphere.h:109
static T sqrt(T x)
Definition: ImathMath.h:114
bool intersect(const Line3< T > &l, Vec3< T > &intersection) const
Definition: ImathSphere.h:159
bool intersectT(const Line3< T > &l, T &t) const
Definition: ImathSphere.h:117