Sphere OBB::MinimalEnclosingSphere() const { Sphere s; s.pos = pos; s.r = HalfDiagonal().Length(); return s; }
void AABB::ProjectToAxis(const float3 &axis, float &dMin, float &dMax) const { float3 c = CenterPoint(); float3 e = HalfDiagonal(); // Compute the projection interval radius of the AABB onto L(t) = aabb.center + t * plane.normal; float r = e[0]*Abs(axis[0]) + e[1]*Abs(axis[1]) + e[2]*Abs(axis[2]); // Compute the distance of the box center from plane. float s = Dot(axis, c); dMin = s - r; dMax = s + r; if (dMin > dMax) Swap(dMin, dMax); }
float3 OBB::Diagonal() const { return 2.f * HalfDiagonal(); }