コード例 #1
0
ファイル: sphere.hpp プロジェクト: mojocorp/gtl
        //! Intersect with an axis aligned box, returning true if there is an intersection.
        bool intersect(const box3<Type>& b) const
        {
            // Arvo's algorithm.
            Type d = 0;

            //find the square of the distance from the sphere to the box
            for (unsigned int i = 0; i < 3; i++) {
                if (m_center[i] < b.getMin()[i]) {
                    Type s = m_center[i] - b.getMin()[i];
                    d += s * s;
                } else if (m_center[i] > b.getMax()[i]) {
                    Type s = m_center[i] - b.getMax()[i];
                    d += s * s;
                }
            }
            return d <= m_radius * m_radius;
        }
コード例 #2
0
ファイル: sphere.hpp プロジェクト: mojocorp/gtl
 //! Make the sphere containing a given box
 void circumscribe(const box3<Type>& box)
 {
     m_center = box.getCenter();
     m_radius = (box.getMax() - m_center).length();
 }