15 #include "boundingLine.h" 16 #include "boundingSphere.h" 17 #include "boundingBox.h" 18 #include "config_mathutil.h" 40 get_approx_center()
const {
56 _origin = _origin * mat;
57 _vector = _vector * mat;
72 output(ostream &out)
const {
74 out <<
"bline, empty";
76 out <<
"bline, infinite";
78 out <<
"bline, (" << _origin <<
") - (" << _origin + _vector <<
")";
101 return other->extend_by_line(
this);
113 return other->around_lines(first, last);
123 return other->contains_line(
this);
137 _origin = line->_origin;
138 _vector = line->_vector;
156 PN_stdfloat r = sphere->get_radius();
158 if (r * r >= sqr_dist_to_line(sphere->get_center())) {
159 return IF_possible | IF_some;
161 return IF_no_intersection;
176 PN_stdfloat r2 = (box->
get_maxq() - box->
get_minq()).length_squared() * 0.25f;
178 if (r2 >= sqr_dist_to_line(center)) {
181 return IF_no_intersection;
190 PN_stdfloat BoundingLine::
191 sqr_dist_to_line(
const LPoint3 &point)
const {
192 nassertr(!point.
is_nan(), 0.0f);
199 PN_stdfloat A = dot(_vector, _vector);
200 nassertr(A != 0.0f, 0.0f);
202 PN_stdfloat B = 2.0 * dot(_vector, fc);
203 PN_stdfloat fc_d2 = dot(fc, fc);
205 PN_stdfloat r2 = fc_d2 - B*B / 4.0*A;
207 nassertr(!cnan(r2), 0.0f);
An axis-aligned bounding box; that is, a minimum and maximum coordinate triple.
bool is_empty() const
Any kind of volume might be empty.
This defines a bounding sphere, consisting of a center and a radius.
bool is_infinite() const
The other side of the empty coin is an infinite volume.
virtual const BoundingLine * as_bounding_line() const
Virtual downcast method.
This is a three-component vector distance (as opposed to a three-component point, which represents a ...
This is a three-component point in space (as opposed to a three-component vector, which represents a ...
bool is_nan() const
Returns true if any component of the vector is not-a-number, false otherwise.
bool is_nan() const
Returns true if any component of the matrix is not-a-number, false otherwise.
bool almost_equal(const LVecBase3f &other, float threshold) const
Returns true if two vectors are memberwise equal within a specified tolerance.
const LPoint3 & get_point_a() const
Returns the first point that defines the line.
This is an abstract class for any volume in any sense which can be said to define the locality of ref...
This is a 4-by-4 transform matrix.
const LPoint3 & get_maxq() const
An inline accessor for the maximum value.
LPoint3 get_point_b() const
Returns the second point that defines the line.
TypeHandle is the identifier used to differentiate C++ class types.
bool normalize()
Normalizes the vector in place.
This funny bounding volume is an infinite line with no thickness and extending to infinity in both di...
const LPoint3 & get_minq() const
An inline accessor for the minimum value.