34 LPoint3 BoundingLine::
35 get_approx_center()
const {
36 nassertr(!
is_empty(), LPoint3(0.0f, 0.0f, 0.0f));
37 nassertr(!
is_infinite(), LPoint3(0.0f, 0.0f, 0.0f));
45 xform(
const LMatrix4 &mat) {
46 nassertv(!mat.is_nan());
49 _origin = _origin * mat;
50 _vector = _vector * mat;
51 if (!_vector.normalize()) {
63 output(std::ostream &out)
const {
65 out <<
"bline, empty";
67 out <<
"bline, infinite";
69 out <<
"bline, (" << _origin <<
") - (" << _origin + _vector <<
")";
87 return other->extend_by_line(
this);
97 return other->around_lines(first, last);
105 return other->contains_line(
this);
117 _origin = line->_origin;
118 _vector = line->_vector;
134 PN_stdfloat r = sphere->get_radius();
136 if (r * r >= sqr_dist_to_line(sphere->get_center())) {
137 return IF_possible | IF_some;
139 return IF_no_intersection;
152 PN_stdfloat r2 = (box->
get_maxq() - box->
get_minq()).length_squared() * 0.25f;
154 if (r2 >= sqr_dist_to_line(center)) {
157 return IF_no_intersection;
164 PN_stdfloat BoundingLine::
165 sqr_dist_to_line(
const LPoint3 &point)
const {
166 nassertr(!point.is_nan(), 0.0f);
168 nassertr(!_vector.almost_equal(LVector3(0.0f, 0.0f, 0.0f)), 0.0f);
173 PN_stdfloat A = dot(_vector, _vector);
174 nassertr(A != 0.0f, 0.0f);
175 LVector3 fc = _origin - point;
176 PN_stdfloat B = 2.0 * dot(_vector, fc);
177 PN_stdfloat fc_d2 = dot(fc, fc);
179 PN_stdfloat r2 = fc_d2 - B*B / 4.0*A;
181 nassertr(!cnan(r2), 0.0f);
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
An axis-aligned bounding box; that is, a minimum and maximum coordinate triple.
const LPoint3 & get_minq() const
An inline accessor for the minimum value.
const LPoint3 & get_maxq() const
An inline accessor for the maximum value.
This funny bounding volume is an infinite line with no thickness and extending to infinity in both di...
LPoint3 get_point_b() const
Returns the second point that defines the line.
const LPoint3 & get_point_a() const
Returns the first point that defines the line.
virtual const BoundingLine * as_bounding_line() const
Virtual downcast method.
This defines a bounding sphere, consisting of a center and a radius.
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
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.
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.