Panda3D
Loading...
Searching...
No Matches
boundingSphere.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file boundingSphere.I
10 * @author drose
11 * @date 1999-10-02
12 */
13
14/**
15 * Constructs an empty sphere.
16 */
17INLINE_MATHUTIL BoundingSphere::
18BoundingSphere() : _center(0) {
19}
20
21/**
22 * Constructs a specific sphere.
23 */
24INLINE_MATHUTIL BoundingSphere::
25BoundingSphere(const LPoint3 &center, PN_stdfloat radius) :
26 _center(center), _radius(radius)
27{
28 _flags = 0;
29 nassertd(!_center.is_nan() && !cnan(_radius)) {
30 _flags = F_empty;
31 }
32}
33
34/**
35 *
36 */
37INLINE_MATHUTIL LPoint3 BoundingSphere::
38get_center() const {
39 nassertr(!is_infinite(), LPoint3::zero());
40 return _center;
41}
42
43/**
44 *
45 */
46INLINE_MATHUTIL PN_stdfloat BoundingSphere::
47get_radius() const {
48 nassertr(!is_empty(), 0.0f);
49 nassertr(!is_infinite(), 0.0f);
50 return _radius;
51}
52
53/**
54 * Sets the center point of the sphere.
55 */
56INLINE_MATHUTIL void BoundingSphere::
57set_center(const LPoint3 &center) {
58 nassertv(!center.is_nan());
59 _center = center;
60}
61
62/**
63 * Sets the radius of the sphere.
64 */
65INLINE_MATHUTIL void BoundingSphere::
66set_radius(PN_stdfloat radius) {
67 nassertv(!cnan(radius));
68 _radius = radius;
69 _flags = 0;
70}
BoundingSphere()
Constructs an empty sphere.
set_radius
Sets the radius of the sphere.
set_center
Sets the center point of the sphere.
bool is_empty() const
Any kind of volume might be empty.
bool is_infinite() const
The other side of the empty coin is an infinite volume.