38#ifdef OSG_USE_FLOAT_PLANE
100 if (&pl==
this)
return *
this;
108 inline void set(
const Vec4f& vec) {
set(vec[0],vec[1],vec[2],vec[3]); }
109 inline void set(
const Vec4d& vec) {
set(vec[0],vec[1],vec[2],vec[3]); }
117 if (length>1e-6) norm/= length;
118 else norm.
set(0.0,0.0,0.0);
119 set(norm[0],norm[1],norm[2],-(v1*norm));
124 value_type d = -norm[0]*point[0] - norm[1]*point[1] - norm[2]*point[2];
125 set(norm[0],norm[1],norm[2],d);
143 _fv[0] *= inv_length;
144 _fv[1] *= inv_length;
145 _fv[2] *= inv_length;
146 _fv[3] *= inv_length;
174 inline bool operator < (
const Plane& plane)
const
176 if (
_fv[0]<plane.
_fv[0])
return true;
177 else if (
_fv[0]>plane.
_fv[0])
return false;
178 else if (
_fv[1]<plane.
_fv[1])
return true;
179 else if (
_fv[1]>plane.
_fv[1])
return false;
180 else if (
_fv[2]<plane.
_fv[2])
return true;
181 else if (
_fv[2]>plane.
_fv[2])
return false;
182 else return (
_fv[3]<plane.
_fv[3]);
238 inline int intersect(
const std::vector<Vec3f>& vertices)
const
240 if (vertices.empty())
return -1;
245 for(std::vector<Vec3f>::const_iterator itr=vertices.begin();
246 itr != vertices.end();
250 if (d>0.0f) ++noAbove;
251 else if (d<0.0f) ++noBelow;
257 if (noBelow>0)
return 0;
267 inline int intersect(
const std::vector<Vec3d>& vertices)
const
269 if (vertices.empty())
return -1;
274 for(std::vector<Vec3d>::const_iterator itr=vertices.begin();
275 itr != vertices.end();
279 if (d>0.0) ++noAbove;
280 else if (d<0.0) ++noBelow;
286 if (noBelow>0)
return 0;
300 if (d>bs.
radius())
return 1;
301 else if (d<-bs.
radius())
return -1;
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
BoundingBoxd BoundingBox
Definition BoundingBox:257
bool isNaN(float v)
Definition Math:133
BoundingSphered BoundingSphere
Definition BoundingSphere:308
Matrixd Matrix
Definition Matrix:27
vec_type & center()
Returns the center of the bounding sphere.
Definition BoundingSphere:77
value_type & radius()
Returns the radius of the bounding sphere.
Definition BoundingSphere:83
const vec_type corner(unsigned int pos) const
Returns a specific corner of the bounding box.
Definition BoundingBox:149
bool invert(const Matrixd &rhs)
invert the matrix rhs, automatically select invert_4x3 or invert_4x4.
Definition Matrixd:233
Plane(const Vec3_type &v1, const Vec3_type &v2, const Vec3_type &v3)
Constructor.
Definition Plane:89
Plane(const Vec3_type &norm, value_type d)
Constructor.
Definition Plane:79
int intersect(const BoundingBox &bb) const
intersection test between plane and bounding sphere.
Definition Plane:310
Plane(const Vec3_type &norm, const Vec3_type &point)
Constructor.
Definition Plane:96
int intersect(const BoundingSphere &bs) const
intersection test between plane and bounding sphere.
Definition Plane:296
void set(const Vec4d &vec)
Definition Plane:109
void set(const Plane &pl)
Definition Plane:105
Plane(value_type a, value_type b, value_type c, value_type d)
Constructor.
Definition Plane:63
double dotProductNormal(const osg::Vec3d &v) const
calculate the dot product of the plane normal and a point.
Definition Plane:227
Vec4_type asVec4() const
Definition Plane:189
void calculateUpperLowerBBCorners()
calculate the upper and lower bounding box corners to be used in the intersect(BoundingBox&) method f...
Definition Plane:151
void set(const Vec3_type &norm, const Vec3_type &point)
Definition Plane:122
Plane(const Vec4f &vec)
Constructor.
Definition Plane:68
int intersect(const std::vector< Vec3f > &vertices) const
intersection test between plane and vertex list return 1 if the bs is completely above plane,...
Definition Plane:238
int intersect(const std::vector< Vec3d > &vertices) const
intersection test between plane and vertex list return 1 if the bs is completely above plane,...
Definition Plane:267
const value_type * ptr() const
Definition Plane:187
double distance(const osg::Vec3d &v) const
Calculate the distance between a point and the plane.
Definition Plane:210
value_type * ptr()
Definition Plane:186
Vec3d Vec3_type
Definition Plane:46
Vec4d Vec4_type
Definition Plane:47
void set(const Vec4f &vec)
Definition Plane:108
float distance(const osg::Vec3f &v) const
Calculate the distance between a point and the plane.
Definition Plane:200
void flip()
flip/reverse the orientation of the plane.
Definition Plane:129
unsigned int _lowerBBCorner
Definition Plane:355
void transform(const osg::Matrix &matrix)
Transform the plane by matrix.
Definition Plane:330
float dotProductNormal(const osg::Vec3f &v) const
calculate the dot product of the plane normal and a point.
Definition Plane:219
void set(const Vec3_type &norm, double d)
Definition Plane:111
double value_type
Type of Plane class.
Definition Plane:45
void set(const Vec3_type &v1, const Vec3_type &v2, const Vec3_type &v3)
Definition Plane:113
Plane()
Default constructor.
Definition Plane:58
Plane(const Vec4d &vec)
Constructor.
Definition Plane:72
void transformProvidingInverse(const osg::Matrix &matrix)
Transform the plane by providing a pre inverted matrix.
Definition Plane:339
bool valid() const
Checks if all internal values describing the plane have valid numbers.
Definition Plane:165
unsigned int _upperBBCorner
Definition Plane:354
void makeUnitLength()
This method multiplies the coefficients of the plane equation with a constant factor so that the equa...
Definition Plane:140
void set(value_type a, value_type b, value_type c, value_type d)
Definition Plane:106
Plane(const Plane &pl)
Definition Plane:59
value_type _fv[4]
Vec member variable.
Definition Plane:351
@ num_components
Definition Plane:51
bool isNaN() const
Definition Plane:166
Vec3_type getNormal() const
Definition Plane:195
General purpose double triple for use as vertices, vectors and normals.
Definition Vec3d:30
value_type & z()
Definition Vec3d:87
void set(value_type x, value_type y, value_type z)
Definition Vec3d:72
value_type & x()
Definition Vec3d:85
value_type & y()
Definition Vec3d:86
value_type length() const
Length of the vector = sqrt( vec .
Definition Vec3d:181
General purpose float triple for use as vertices, vectors and normals.
Definition Vec3f:29
value_type & z()
Definition Vec3f:82
value_type & y()
Definition Vec3f:81
value_type & x()
Definition Vec3f:80
General purpose double quad.
Definition Vec4d:29
General purpose float quad.
Definition Vec4f:28
#define OSG_EXPORT
Definition Export:39