OpenSceneGraph 3.6.5
LineSegment
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2004 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSG_LINESEGMENT
15#define OSG_LINESEGMENT 1
16
17#include <osg/Matrix>
18#include <osg/BoundingBox>
19#include <osg/BoundingSphere>
20
21namespace osg {
22
25{
26 public:
27
28 typedef Vec3d vec_type;
30
32 LineSegment(const LineSegment& seg) : Referenced(),_s(seg._s),_e(seg._e) {}
33 LineSegment(const vec_type& s,const vec_type& e) : _s(s),_e(e) {}
34
35 LineSegment& operator = (const LineSegment& seg) { _s = seg._s; _e = seg._e; return *this; }
36
37 inline void set(const vec_type& s,const vec_type& e) { _s=s; _e=e; }
38
39 inline vec_type& start() { return _s; }
40 inline const vec_type& start() const { return _s; }
41
42 inline vec_type& end() { return _e; }
43 inline const vec_type& end() const { return _e; }
44
45 inline bool valid() const { return _s.valid() && _e.valid() && _s!=_e; }
46
47
49 bool intersect(const BoundingBox& bb) const;
50
54 bool intersectAndComputeRatios(const BoundingBox& bb, float& ratioFromStartToEnd1, float& ratioFromStartToEnd2) const;
55
59 bool intersectAndComputeRatios(const BoundingBox& bb, double& ratioFromStartToEnd1, double& ratioFromStartToEnd2) const;
60
61
63 bool intersect(const BoundingSphere& bs) const;
64
68 bool intersectAndComputeRatios(const BoundingSphere& bs, float& ratioFromStartToEnd1, float& ratioFromStartToEnd2) const;
69
73 bool intersectAndComputeRatios(const BoundingSphere& bs,double& ratioFromStartToEnd1, double& ratioFromStartToEnd2) const;
74
78 bool intersect(const Vec3f& v1,const Vec3f& v2,const Vec3f& v3,float& ratioFromStartToEnd);
79
83 bool intersect(const Vec3d& v1,const Vec3d& v2,const Vec3d& v3,double& ratioFromStartToEnd);
84
85
87 inline void mult(const LineSegment& seg,const Matrix& m) { _s = seg._s*m; _e = seg._e*m; }
88
90 inline void mult(const Matrix& m,const LineSegment& seg) { _s = m*seg._s; _e = m*seg._e; }
91
92 protected:
93
94 virtual ~LineSegment();
95
96 static bool intersectAndClip(vec_type& s,vec_type& e,const BoundingBox& bb);
97
100};
101
102}
103
104#endif
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
BoundingBoxd BoundingBox
Definition BoundingBox:257
BoundingSphered BoundingSphere
Definition BoundingSphere:308
Matrixd Matrix
Definition Matrix:27
vec_type::value_type value_type
Definition LineSegment:29
bool intersect(const Vec3d &v1, const Vec3d &v2, const Vec3d &v3, double &ratioFromStartToEnd)
return true if segment intersects triangle and set double ratios where the ratio is 0....
bool intersectAndComputeRatios(const BoundingBox &bb, float &ratioFromStartToEnd1, float &ratioFromStartToEnd2) const
return true if segment intersects BoundingBox and set float ratios for the first and second intersect...
const vec_type & start() const
Definition LineSegment:40
const vec_type & end() const
Definition LineSegment:43
LineSegment()
Definition LineSegment:31
vec_type _e
Definition LineSegment:99
void mult(const LineSegment &seg, const Matrix &m)
post multiply a segment by matrix.
Definition LineSegment:87
void mult(const Matrix &m, const LineSegment &seg)
pre multiply a segment by matrix.
Definition LineSegment:90
bool intersect(const Vec3f &v1, const Vec3f &v2, const Vec3f &v3, float &ratioFromStartToEnd)
return true if segment intersects triangle and set float ratios where the ratio is 0....
LineSegment(const LineSegment &seg)
Definition LineSegment:32
LineSegment(const vec_type &s, const vec_type &e)
Definition LineSegment:33
bool intersectAndComputeRatios(const BoundingBox &bb, double &ratioFromStartToEnd1, double &ratioFromStartToEnd2) const
return true if segment intersects BoundingBox and set double ratios for the first and second intersec...
vec_type & end()
Definition LineSegment:42
static bool intersectAndClip(vec_type &s, vec_type &e, const BoundingBox &bb)
bool valid() const
Definition LineSegment:45
bool intersect(const BoundingSphere &bs) const
return true if segment intersects BoundingSphere.
bool intersect(const BoundingBox &bb) const
return true if segment intersects BoundingBox.
virtual ~LineSegment()
Vec3d vec_type
Definition LineSegment:28
vec_type _s
Definition LineSegment:98
vec_type & start()
Definition LineSegment:39
void set(const vec_type &s, const vec_type &e)
Definition LineSegment:37
bool intersectAndComputeRatios(const BoundingSphere &bs, double &ratioFromStartToEnd1, double &ratioFromStartToEnd2) const
return true if segment intersects BoundingSphere and set double ratios for the first and second inter...
bool intersectAndComputeRatios(const BoundingSphere &bs, float &ratioFromStartToEnd1, float &ratioFromStartToEnd2) const
return true if segment intersects BoundingSphere and set float ratios for the first and second inters...
General purpose double triple for use as vertices, vectors and normals.
Definition Vec3d:30
double value_type
Data type of vector components.
Definition Vec3d:34
General purpose float triple for use as vertices, vectors and normals.
Definition Vec3f:29
#define OSG_EXPORT
Definition Export:39

osg logo
Generated at Sun Jul 20 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.