Panda3D
 All Classes Functions Variables Enumerations
boundingSphere.I
1 // Filename: boundingSphere.I
2 // Created by: drose (02Oct99)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: BoundingSphere::Constructor
18 // Access: Published
19 // Description: Constructs an empty sphere.
20 ////////////////////////////////////////////////////////////////////
21 INLINE_MATHUTIL BoundingSphere::
23 }
24 
25 ////////////////////////////////////////////////////////////////////
26 // Function: BoundingSphere::Constructor
27 // Access: Published
28 // Description: Constructs a specific sphere.
29 ////////////////////////////////////////////////////////////////////
30 INLINE_MATHUTIL BoundingSphere::
31 BoundingSphere(const LPoint3 &center, PN_stdfloat radius) :
32  _center(center), _radius(radius)
33 {
34  _flags = 0;
35  nassertd(!_center.is_nan() && !cnan(_radius)) {
36  _flags = F_empty;
37  }
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: BoundingSphere::get_center
42 // Access: Published
43 // Description:
44 ////////////////////////////////////////////////////////////////////
45 INLINE_MATHUTIL LPoint3 BoundingSphere::
46 get_center() const {
47  nassertr(!is_empty(), LPoint3::zero());
48  nassertr(!is_infinite(), LPoint3::zero());
49  return _center;
50 }
51 
52 ////////////////////////////////////////////////////////////////////
53 // Function: BoundingSphere::get_radius
54 // Access: Published
55 // Description:
56 ////////////////////////////////////////////////////////////////////
57 INLINE_MATHUTIL PN_stdfloat BoundingSphere::
58 get_radius() const {
59  nassertr(!is_empty(), 0.0f);
60  nassertr(!is_infinite(), 0.0f);
61  return _radius;
62 }
63 
static const LPoint3f & zero()
Returns a zero-length point.
Definition: lpoint3.h:258
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
Definition: lpoint3.h:99
bool is_nan() const
Returns true if any component of the vector is not-a-number, false otherwise.
Definition: lvecBase3.h:463
bool is_infinite() const
The other side of the empty coin is an infinite volume.
BoundingSphere()
Constructs an empty sphere.
bool is_empty() const
Any kind of volume might be empty.