LineSegment
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2004 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_LINESEGMENT
#define OSG_LINESEGMENT 1
#include <osg/Matrix>
#include <osg/BoundingBox>
#include <osg/BoundingSphere>
namespace osg {
class OSG_EXPORT LineSegment : public Referenced
{
public:
typedef Vec3d vec_type;
typedef vec_type::value_type value_type;
LineSegment() {};
LineSegment(const LineSegment& seg) : Referenced(),_s(seg._s),_e(seg._e) {}
LineSegment(const vec_type& s,const vec_type& e) : _s(s),_e(e) {}
LineSegment& operator = (const LineSegment& seg) { _s = seg._s; _e = seg._e; return *this; }
inline void set(const vec_type& s,const vec_type& e) { _s=s; _e=e; }
inline vec_type& start() { return _s; }
inline const vec_type& start() const { return _s; }
inline vec_type& end() { return _e; }
inline const vec_type& end() const { return _e; }
inline bool valid() const { return _s.valid() && _e.valid() && _s!=_e; }
bool intersect(const BoundingBox& bb) const;
bool intersectAndComputeRatios(const BoundingBox& bb, float& ratioFromStartToEnd1, float& ratioFromStartToEnd2) const;
bool intersectAndComputeRatios(const BoundingBox& bb, double& ratioFromStartToEnd1, double& ratioFromStartToEnd2) const;
bool intersect(const BoundingSphere& bs) const;
bool intersectAndComputeRatios(const BoundingSphere& bs, float& ratioFromStartToEnd1, float& ratioFromStartToEnd2) const;
bool intersectAndComputeRatios(const BoundingSphere& bs,double& ratioFromStartToEnd1, double& ratioFromStartToEnd2) const;
bool intersect(const Vec3f& v1,const Vec3f& v2,const Vec3f& v3,float& ratioFromStartToEnd);
bool intersect(const Vec3d& v1,const Vec3d& v2,const Vec3d& v3,double& ratioFromStartToEnd);
inline void mult(const LineSegment& seg,const Matrix& m) { _s = seg._s*m; _e = seg._e*m; }
inline void mult(const Matrix& m,const LineSegment& seg) { _s = m*seg._s; _e = m*seg._e; }
protected:
virtual ~LineSegment();
static bool intersectAndClip(vec_type& s,vec_type& e,const BoundingBox& bb);
vec_type _s;
vec_type _e;
};
}
#endif
BoundingBox
BoundingSphere
Matrix
osg::LineSegment::value_type
vec_type::value_type value_type
Definition LineSegment:29
osg::LineSegment::intersect
bool intersect(const Vec3d &v1, const Vec3d &v2, const Vec3d &v3, double &ratioFromStartToEnd)
osg::LineSegment::intersectAndComputeRatios
bool intersectAndComputeRatios(const BoundingBox &bb, float &ratioFromStartToEnd1, float &ratioFromStartToEnd2) const
osg::LineSegment::start
const vec_type & start() const
Definition LineSegment:40
osg::LineSegment::end
const vec_type & end() const
Definition LineSegment:43
osg::LineSegment::LineSegment
LineSegment()
Definition LineSegment:31
osg::LineSegment::_e
vec_type _e
Definition LineSegment:99
osg::LineSegment::mult
void mult(const LineSegment &seg, const Matrix &m)
Definition LineSegment:87
osg::LineSegment::mult
void mult(const Matrix &m, const LineSegment &seg)
Definition LineSegment:90
osg::LineSegment::intersect
bool intersect(const Vec3f &v1, const Vec3f &v2, const Vec3f &v3, float &ratioFromStartToEnd)
osg::LineSegment::LineSegment
LineSegment(const LineSegment &seg)
Definition LineSegment:32
osg::LineSegment::LineSegment
LineSegment(const vec_type &s, const vec_type &e)
Definition LineSegment:33
osg::LineSegment::intersectAndComputeRatios
bool intersectAndComputeRatios(const BoundingBox &bb, double &ratioFromStartToEnd1, double &ratioFromStartToEnd2) const
osg::LineSegment::end
vec_type & end()
Definition LineSegment:42
osg::LineSegment::intersectAndClip
static bool intersectAndClip(vec_type &s, vec_type &e, const BoundingBox &bb)
osg::LineSegment::valid
bool valid() const
Definition LineSegment:45
osg::LineSegment::intersect
bool intersect(const BoundingSphere &bs) const
osg::LineSegment::intersect
bool intersect(const BoundingBox &bb) const
osg::LineSegment::~LineSegment
virtual ~LineSegment()
osg::LineSegment::vec_type
Vec3d vec_type
Definition LineSegment:28
osg::LineSegment::_s
vec_type _s
Definition LineSegment:98
osg::LineSegment::start
vec_type & start()
Definition LineSegment:39
osg::LineSegment::set
void set(const vec_type &s, const vec_type &e)
Definition LineSegment:37
osg::LineSegment::intersectAndComputeRatios
bool intersectAndComputeRatios(const BoundingSphere &bs, double &ratioFromStartToEnd1, double &ratioFromStartToEnd2) const
osg::LineSegment::intersectAndComputeRatios
bool intersectAndComputeRatios(const BoundingSphere &bs, float &ratioFromStartToEnd1, float &ratioFromStartToEnd2) const
osg::Referenced::Referenced
Referenced()
osg::Vec3d
Definition Vec3d:30
osg::Vec3d::value_type
double value_type
Definition Vec3d:34
osg::Vec3f
Definition Vec3f:29
osg
Definition AlphaFunc:19
osg::BoundingBox
BoundingBoxd BoundingBox
Definition BoundingBox:257
osg::BoundingSphere
BoundingSphered BoundingSphere
Definition BoundingSphere:314
osg::Matrix
Matrixd Matrix
Definition Matrix:27
OSG_EXPORT
#define OSG_EXPORT
Definition osg/Export:39