Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
SbPlane.h
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2022 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23#ifndef _SB_PLANE_
24#define _SB_PLANE_
25
26#include <Inventor/SbVec.h>
27
28class SbLine;
29class SbMatrix;
30
32//
33// Class: SbPlane
34//
35// Represents an oriented plane in 3D space. The plane is defined by
36// a plane normal and a distance from the origin along that normal.
37// SbPlanes may be used to represent either planes or half-spaces. In
38// the latter case (as for the isInHalfSpace() method), the
39// half-space is defined to be all points on the plane or on the side
40// of the plane in the direction of the plane normal.
41//
42// The 4 coefficients of the plane equation of an SbPlane can be
43// obtained easily as the 3 coordinates of the plane normal and the
44// distance, in that order.
45//
47
48
64class SbPlane {
65public:
70
75 SbPlane(const SbVec3f &p0, const SbVec3f &p1, const SbVec3f &p2);
76
82 SbPlane(const SbVec3f &normal, float distance);
83
89 SbPlane(const SbVec3f &normal, const SbVec3f &point);
90
94 void offset(float d);
95
101 SbVec3f &intersection) const;
102
106 void transform(const SbMatrix &matrix);
107
111 SbBool isInHalfSpace(const SbVec3f &point) const;
112
113
117 const SbVec3f &getNormal() const { return normalVec; }
121 float getDistanceFromOrigin() const { return distance; }
122
126 friend int operator ==(const SbPlane &p1, const SbPlane &p2);
130 friend int operator !=(const SbPlane &p1, const SbPlane &p2)
131 { return !(p1 == p2); }
132
136 float getDistance(const SbVec3f &point) const;
137
138private:
142 enum PlanePlaneIntersectionResult
143 {
144 DISJOINT_PARALLEL_PLANES = 0,
145 COINCIDENT_PLANES = 1,
146 INCIDENT_PLANES = 2,
147 };
148
155 PlanePlaneIntersectionResult intersect( const SbPlane &p, SbLine &intersection, float angTol = 10.e-3f ) const;
156
157private:
158 // Plane is all p such that normalVec . p - distance = 0
159
160 // Normal to the plane
161 SbVec3f normalVec;
162
163 // Distance from origin to plane: distance * normalVec is on the plane
164 float distance;
165
166};
167
168
169#endif /* _SB_PLANE_ */
170
171
Directed line in 3D.
Definition SbLine.h:57
4x4 matrix class.
Definition SbMatrix.h:309
Oriented plane in 3D.
Definition SbPlane.h:64
SbBool intersect(const SbLine &l, SbVec3f &intersection) const
Intersect line and plane, returning TRUE if there is an intersection, FALSE if line is parallel to pl...
float getDistanceFromOrigin() const
Returns distance from origin to plane.
Definition SbPlane.h:121
float getDistance(const SbVec3f &point) const
Returns the distance from a point to plane.
void transform(const SbMatrix &matrix)
Transforms the plane by the given matrix.
friend int operator!=(const SbPlane &p1, const SbPlane &p2)
Inequality comparison operator.
Definition SbPlane.h:130
SbPlane()
Default constructor.
Definition SbPlane.h:69
SbPlane(const SbVec3f &normal, float distance)
Constructor.
void offset(float d)
Offset a plane by a given distance.
friend int operator==(const SbPlane &p1, const SbPlane &p2)
Equality comparison operator.
const SbVec3f & getNormal() const
Returns normal vector to plane.
Definition SbPlane.h:117
SbPlane(const SbVec3f &p0, const SbVec3f &p1, const SbVec3f &p2)
Constructor.
SbPlane(const SbVec3f &normal, const SbVec3f &point)
Constructor.
SbBool isInHalfSpace(const SbVec3f &point) const
Returns TRUE if the given point is within the half-space defined by the plane.
3D vector class.
Definition SbVec.h:932
int SbBool
Boolean type.
Definition SbBase.h:87