PageRenderTime 38ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llmath/llsphere.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 77 lines | 29 code | 15 blank | 33 comment | 0 complexity | 3fa6442a08a5253c43d2b6b3966e51a7 MD5 | raw file
Possible License(s): LGPL-2.1
  1. // llsphere.h
  2. /**
  3. * @file llsphere.cpp
  4. * @author Andrew Meadows
  5. * @brief Simple sphere implementation for basic geometric operations
  6. *
  7. * $LicenseInfo:firstyear=2007&license=viewerlgpl$
  8. * Second Life Viewer Source Code
  9. * Copyright (C) 2010, Linden Research, Inc.
  10. *
  11. * This library is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU Lesser General Public
  13. * License as published by the Free Software Foundation;
  14. * version 2.1 of the License only.
  15. *
  16. * This library is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * Lesser General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public
  22. * License along with this library; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. *
  25. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  26. * $/LicenseInfo$
  27. */
  28. #ifndef LL_SPHERE_H
  29. #define LL_SPHERE_H
  30. #include "stdtypes.h"
  31. #include "v3math.h"
  32. #include <iostream>
  33. #include <vector>
  34. class LLSphere
  35. {
  36. public:
  37. LLSphere();
  38. LLSphere( const LLVector3& center, F32 radius );
  39. void set( const LLVector3& center, F32 radius );
  40. void setCenter( const LLVector3& center );
  41. void setRadius( F32 radius );
  42. const LLVector3& getCenter() const;
  43. F32 getRadius() const;
  44. // returns TRUE if this sphere completely contains other_sphere
  45. BOOL contains(const LLSphere& other_sphere) const;
  46. // returns TRUE if this sphere overlaps other_sphere
  47. BOOL overlaps(const LLSphere& other_sphere) const;
  48. // returns overlap distance
  49. // negative overlap is closest approach
  50. F32 getOverlap(const LLSphere& other_sphere) const;
  51. // removes any spheres that are contained in others
  52. static void collapse(std::vector<LLSphere>& sphere_list);
  53. // returns minimum sphere bounding sphere for a set of spheres
  54. static LLSphere getBoundingSphere(const LLSphere& first_sphere, const LLSphere& second_sphere);
  55. static LLSphere getBoundingSphere(const std::vector<LLSphere>& sphere_list);
  56. bool operator==(const LLSphere& rhs) const;
  57. friend std::ostream& operator<<( std::ostream& output_stream, const LLSphere& line );
  58. protected:
  59. LLVector3 mCenter;
  60. F32 mRadius;
  61. };
  62. #endif