Mesh Oriented datABase  (version 5.5.0)
An array-based unstructured mesh library
moab::BSPTree::Plane Struct Reference

struct to store a plane More...

#include <BSPTree.hpp>

Public Member Functions

 Plane ()
 
 Plane (const double n[3], double d)
 
 Plane (double a, double b, double c, double d)
 
 Plane (Axis normal, double point_on_axis)
 
double signed_distance (const double point[3]) const
 
bool below (const double point[3]) const
 
bool above (const double point[3]) const
 
double distance (const double point[3]) const
 
void flip ()
 
void set (const double normal[3], const double point[3])
 
void set (const double pt1[3], const double pt2[3], const double pt3[3])
 
void set (double i, double j, double k, double cff)
 
void set (Axis normal, double point_on_axis)
 

Public Attributes

double norm [3]
 Unit normal of plane. More...
 
double coeff
 norm[0]*x + norm[1]*y + norm[2]*z + coeff = 0 More...
 

Detailed Description

struct to store a plane

If plane is defined as Ax+By+Cz+D=0, then norm={A,B,C} and coeff=-D.

Definition at line 81 of file BSPTree.hpp.

Constructor & Destructor Documentation

◆ Plane() [1/4]

moab::BSPTree::Plane::Plane ( )
inline

Definition at line 83 of file BSPTree.hpp.

83 : coeff( 0.0 ) {}

Referenced by set().

◆ Plane() [2/4]

moab::BSPTree::Plane::Plane ( const double  n[3],
double  d 
)
inline

Definition at line 84 of file BSPTree.hpp.

84  : coeff( d )
85  {
86  norm[0] = n[0];
87  norm[1] = n[1];
88  norm[2] = n[2];
89  }

References norm.

◆ Plane() [3/4]

moab::BSPTree::Plane::Plane ( double  a,
double  b,
double  c,
double  d 
)
inline

a x + b y + c z + d = 0

Definition at line 91 of file BSPTree.hpp.

91  : coeff( d )
92  {
93  norm[0] = a;
94  norm[1] = b;
95  norm[2] = c;
96  }

References norm.

◆ Plane() [4/4]

moab::BSPTree::Plane::Plane ( Axis  normal,
double  point_on_axis 
)
inline

Create Y = 1 plane by doing Plane( Y, 1.0 );

Definition at line 98 of file BSPTree.hpp.

98  : coeff( -point_on_axis )
99  {
100  norm[0] = norm[1] = norm[2] = 0;
101  norm[normal] = 1.0;
102  }

References norm.

Member Function Documentation

◆ above()

bool moab::BSPTree::Plane::above ( const double  point[3]) const
inline

return true if point is above the plane

Definition at line 124 of file BSPTree.hpp.

125  {
126  return signed_distance( point ) >= 0.0;
127  }

References signed_distance().

Referenced by moab::BSPTreeBoxIter::intersects(), moab::BSPTree::leaf_containing_point(), and moab::BSPTreeBoxIter::side_above_plane().

◆ below()

bool moab::BSPTree::Plane::below ( const double  point[3]) const
inline

return true if point is below the plane

Definition at line 118 of file BSPTree.hpp.

119  {
120  return signed_distance( point ) <= 0.0;
121  }

References signed_distance().

◆ distance()

double moab::BSPTree::Plane::distance ( const double  point[3]) const
inline

Definition at line 129 of file BSPTree.hpp.

130  {
131  return fabs( signed_distance( point ) );
132  }

References signed_distance().

Referenced by moab::BSPTreeBoxIter::side_on_plane().

◆ flip()

void moab::BSPTree::Plane::flip ( )
inline

reverse plane normal

Definition at line 135 of file BSPTree.hpp.

136  {
137  norm[0] = -norm[0];
138  norm[1] = -norm[1];
139  norm[2] = -norm[2];
140  coeff = -coeff;
141  }

References coeff, and norm.

Referenced by moab::BSPTreeIter::calculate_polyhedron(), moab::BSPTreeBoxIter::down(), moab::BSPTreePlaneIter::operator++(), moab::BSPTreeBoxIter::step(), and moab::BSPTreeBoxIter::step_to_first_leaf().

◆ set() [1/4]

void moab::BSPTree::Plane::set ( Axis  normal,
double  point_on_axis 
)
inline

Create Y = 1 plane by doing set( Y, 1.0 );

Definition at line 157 of file BSPTree.hpp.

158  {
159  coeff = -point_on_axis;
160  norm[0] = norm[1] = norm[2] = 0;
161  norm[normal] = 1.0;
162  }

References coeff, and norm.

◆ set() [2/4]

void moab::BSPTree::Plane::set ( const double  normal[3],
const double  point[3] 
)
inline

Definition at line 143 of file BSPTree.hpp.

144  {
145  const double dot = normal[0] * point[0] + normal[1] * point[1] + normal[2] * point[2];
146  *this = Plane( normal, -dot );
147  }

References moab::dot(), and Plane().

Referenced by set().

◆ set() [3/4]

void moab::BSPTree::Plane::set ( const double  pt1[3],
const double  pt2[3],
const double  pt3[3] 
)

Definition at line 84 of file BSPTree.cpp.

85 {
86  const double v1[] = { pt2[0] - pt1[0], pt2[1] - pt1[1], pt2[2] - pt1[2] };
87  const double v2[] = { pt3[0] - pt1[0], pt3[1] - pt1[1], pt3[2] - pt1[2] };
88  const double nrm[] = { v1[1] * v2[2] - v1[2] * v2[1], v1[2] * v2[0] - v1[0] * v2[2],
89  v1[0] * v2[1] - v1[1] * v2[0] };
90  set( nrm, pt1 );
91 }

References set().

◆ set() [4/4]

void moab::BSPTree::Plane::set ( double  i,
double  j,
double  k,
double  cff 
)
inline

Definition at line 151 of file BSPTree.hpp.

152  {
153  *this = Plane( i, j, k, cff );
154  }

References Plane().

◆ signed_distance()

double moab::BSPTree::Plane::signed_distance ( const double  point[3]) const
inline

Signed distance from point to plane: absolute value is distance from point to plane positive if 'above' plane, negative if 'below' Note: assumes unit-length normal.

Definition at line 112 of file BSPTree.hpp.

113  {
114  return point[0] * norm[0] + point[1] * norm[1] + point[2] * norm[2] + coeff;
115  }

References coeff, and norm.

Referenced by above(), below(), distance(), moab::BSPTreeBoxIter::get_neighbors(), and moab::BSPTreeBoxIter::splits().

Member Data Documentation

◆ coeff

double moab::BSPTree::Plane::coeff

norm[0]*x + norm[1]*y + norm[2]*z + coeff = 0

Definition at line 105 of file BSPTree.hpp.

Referenced by moab::BSPTreeIter::calculate_polyhedron(), flip(), moab::plane_cut_edge(), set(), moab::BSPTree::set_split_plane(), and signed_distance().

◆ norm

double moab::BSPTree::Plane::norm[3]

The documentation for this struct was generated from the following files: