aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmath/llsphere.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llmath/llsphere.h72
1 files changed, 72 insertions, 0 deletions
diff --git a/linden/indra/llmath/llsphere.h b/linden/indra/llmath/llsphere.h
new file mode 100644
index 0000000..4d7cd7a
--- /dev/null
+++ b/linden/indra/llmath/llsphere.h
@@ -0,0 +1,72 @@
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=2001&license=internal$
8 *
9 * Copyright (c) 2001-2008, Linden Research, Inc.
10 *
11 * The following source code is PROPRIETARY AND CONFIDENTIAL. Use of
12 * this source code is governed by the Linden Lab Source Code Disclosure
13 * Agreement ("Agreement") previously entered between you and Linden
14 * Lab. By accessing, using, copying, modifying or distributing this
15 * software, you acknowledge that you have been informed of your
16 * obligations under the Agreement and agree to abide by those obligations.
17 *
18 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
19 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
20 * COMPLETENESS OR PERFORMANCE.
21 * $/LicenseInfo$
22 */
23
24#ifndef LL_SPHERE_H
25#define LL_SPHERE_H
26
27#include "stdtypes.h"
28#include "v3math.h"
29#include <iostream>
30#include <vector>
31
32class LLSphere
33{
34public:
35 LLSphere();
36 LLSphere( const LLVector3& center, F32 radius );
37
38 void set( const LLVector3& center, F32 radius );
39 void setCenter( const LLVector3& center );
40 void setRadius( F32 radius );
41
42 const LLVector3& getCenter() const;
43 F32 getRadius() const;
44
45 // returns TRUE if this sphere completely contains other_sphere
46 BOOL contains(const LLSphere& other_sphere) const;
47
48 // returns TRUE if this sphere overlaps other_sphere
49 BOOL overlaps(const LLSphere& other_sphere) const;
50
51 // returns overlap distance
52 // negative overlap is closest approach
53 F32 getOverlap(const LLSphere& other_sphere) const;
54
55 // removes any spheres that are contained in others
56 static void collapse(std::vector<LLSphere>& sphere_list);
57
58 // returns minimum sphere bounding sphere for a set of spheres
59 static LLSphere getBoundingSphere(const LLSphere& first_sphere, const LLSphere& second_sphere);
60 static LLSphere getBoundingSphere(const std::vector<LLSphere>& sphere_list);
61
62 bool operator==(const LLSphere& rhs) const;
63
64 friend std::ostream& operator<<( std::ostream& output_stream, const LLSphere& line );
65
66protected:
67 LLVector3 mCenter;
68 F32 mRadius;
69};
70
71
72#endif