//=======================================================================// // File: sphere.cpp // // Project: Architecture // // Author: J.M. Albertson // //-----------------------------------------------------------------------// // Copyright (C) 1994, Virtual World Entertainments, All Rights reserved // // PROPRIETARY AND CONFIDENTIAL // //=======================================================================// #include #pragma hdrstop #if !defined(SPHERE_HPP) # include #endif // //########################################################################### //########################################################################### // Logical Sphere::Contains(const Point3D &A_Point) const { Vector3D diff; diff.Subtract(center,A_Point); return radius*radius >= diff.LengthSquared(); } // //########################################################################### //########################################################################### // Logical Sphere::Intersects(const Sphere &sphere) const { Vector3D temp; Scalar r; r = radius + sphere.radius; temp.Subtract(center, sphere.center); return temp.LengthSquared() <= r*r; } // //########################################################################### //########################################################################### // ostream& operator<<(ostream& Stream, const Sphere &A_Sphere) { Stream << "\n\tSphere Centerpoint: " << A_Sphere.center; return Stream << "\n\tRadius: " << A_Sphere.radius; }