libMesh::Plane Class Reference

A geometric object representing a planar surface. More...

#include <plane.h>

Inheritance diagram for libMesh::Plane:

Public Member Functions

 Plane ()
 
 Plane (const Point &p, const Point &n)
 
 Plane (const Point &p0, const Point &p1, const Point &p2)
 
 Plane (const Plane &other_plane)
 
 ~Plane ()
 
void create_from_point_normal (const Point &p, const Point &n)
 
void create_from_three_points (const Point &p0, const Point &p1, const Point &p2)
 
void xy_plane (const Real zpos=0.)
 
void xz_plane (const Real ypos=0.)
 
void yz_plane (const Real xpos=0.)
 
virtual bool above_surface (const Point &p) const override
 
virtual bool below_surface (const Point &p) const override
 
virtual bool on_surface (const Point &p) const override
 
virtual Point closest_point (const Point &p) const override
 
virtual Point unit_normal (const Point &p) const override
 
const Pointget_planar_point () const
 
virtual Point surface_coords (const Point &world_coords) const
 
virtual Point world_coords (const Point &surf_coords) const
 

Private Member Functions

const Pointnormal () const
 

Private Attributes

Point _point
 
Point _normal
 

Detailed Description

A geometric object representing a planar surface.

This class defines a plane.

Author
Benjamin S. Kirk
Date
2002

Definition at line 36 of file plane.h.

Constructor & Destructor Documentation

◆ Plane() [1/4]

libMesh::Plane::Plane ( )

Dummy Constructor.

Definition at line 32 of file plane.C.

33 {
34 }

◆ Plane() [2/4]

libMesh::Plane::Plane ( const Point p,
const Point n 
)

Constructs a plane containing point p with normal n.

Definition at line 38 of file plane.C.

References create_from_point_normal().

40 {
41  this->create_from_point_normal (p, n);
42 }
void create_from_point_normal(const Point &p, const Point &n)
Definition: plane.C:70

◆ Plane() [3/4]

libMesh::Plane::Plane ( const Point p0,
const Point p1,
const Point p2 
)

Constructs a plane containing the three points. The normal is determined in a counter-clockwise sense. See the create_from_three_points method for more details.

Definition at line 46 of file plane.C.

References create_from_three_points().

49 {
50  this->create_from_three_points (p0, p1, p2);
51 }
void create_from_three_points(const Point &p0, const Point &p1, const Point &p2)
Definition: plane.C:78

◆ Plane() [4/4]

libMesh::Plane::Plane ( const Plane other_plane)

Copy-constructor.

Definition at line 55 of file plane.C.

References _normal, _point, and create_from_point_normal().

55  :
56  Surface()
57 {
58  this->create_from_point_normal(other_plane._point,
59  other_plane._normal);
60 }
void create_from_point_normal(const Point &p, const Point &n)
Definition: plane.C:70

◆ ~Plane()

libMesh::Plane::~Plane ( )

Destructor. Does nothing at the moment.

Definition at line 64 of file plane.C.

65 {
66 }

Member Function Documentation

◆ above_surface()

bool libMesh::Plane::above_surface ( const Point p) const
overridevirtual
Returns
true if the point p is above the surface, false otherwise.

Implements libMesh::Surface.

Definition at line 127 of file plane.C.

References _point, normal(), and libMesh::Real.

Referenced by below_surface().

128 {
129  // Create a vector from the surface to point p;
130  const Point w = p - _point;
131 
132  // The point is above the surface if the projection
133  // of that vector onto the normal is positive
134  const Real proj = w*this->normal();
135 
136  if (proj > 0.)
137  return true;
138 
139  return false;
140 }
Point _point
Definition: plane.h:144
const Point & normal() const
Definition: plane.h:139
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ below_surface()

bool libMesh::Plane::below_surface ( const Point p) const
overridevirtual
Returns
true if the point p is below the surface, false otherwise.

Implements libMesh::Surface.

Definition at line 144 of file plane.C.

References above_surface().

145 {
146  return ( !this->above_surface (p) );
147 }
virtual bool above_surface(const Point &p) const override
Definition: plane.C:127

◆ closest_point()

Point libMesh::Plane::closest_point ( const Point p) const
overridevirtual
Returns
The closest point on the surface to point p.

Implements libMesh::Surface.

Definition at line 169 of file plane.C.

References _point, and normal().

170 {
171  // Create a vector from the surface to point p;
172  const Point w = p - _point;
173 
174  // The closest point in the plane to point p
175  // is in the negative normal direction
176  // a distance w (dot) p.
177  const Point cp = p - this->normal()*(w*this->normal());
178 
179  return cp;
180 }
Point _point
Definition: plane.h:144
const Point & normal() const
Definition: plane.h:139

◆ create_from_point_normal()

void libMesh::Plane::create_from_point_normal ( const Point p,
const Point n 
)

Defines a plane containing point p with normal n.

Definition at line 70 of file plane.C.

References _normal, _point, and libMesh::TypeVector< T >::unit().

Referenced by Plane().

71 {
72  _normal = n.unit();
73  _point = p;
74 }
Point _point
Definition: plane.h:144
TypeVector< T > unit() const
Definition: type_vector.C:37
Point _normal
Definition: plane.h:145

◆ create_from_three_points()

void libMesh::Plane::create_from_three_points ( const Point p0,
const Point p1,
const Point p2 
)

Defines a plane intersecting the three points p0, p1, and p2. The normal is constructed in a counter-clockwise sense, i.e. (p1-p0)x(p2-p0);

Definition at line 78 of file plane.C.

References _normal, _point, libMesh::TypeVector< T >::cross(), and libMesh::TypeVector< T >::unit().

Referenced by Plane().

81 {
82  // Just use p0 for the point.
83  _point = p0;
84 
85  const Point e0 = p1 - p0;
86  const Point e1 = p2 - p0;
87  const Point n = e0.cross(e1);
88 
89  _normal = n.unit();
90 }
Point _point
Definition: plane.h:144
TypeVector< T > unit() const
Definition: type_vector.C:37
TypeVector< typename CompareTypes< T, T2 >::supertype > cross(const TypeVector< T2 > &v) const
Definition: type_vector.h:882
Point _normal
Definition: plane.h:145

◆ get_planar_point()

const Point & libMesh::Plane::get_planar_point ( ) const
Returns
A point on the plane useful for determining position.

Definition at line 189 of file plane.C.

References _point.

190 {
191  return _point;
192 }
Point _point
Definition: plane.h:144

◆ normal()

const Point& libMesh::Plane::normal ( ) const
inlineprivate
Returns
The normal for the plane.

Definition at line 139 of file plane.h.

References _normal.

Referenced by above_surface(), closest_point(), and on_surface().

139 { return _normal; }
Point _normal
Definition: plane.h:145

◆ on_surface()

bool libMesh::Plane::on_surface ( const Point p) const
overridevirtual
Returns
true if the point p is on the surface, false otherwise.
Note
The definition of "on the surface" really means "very close" to account for roundoff error.

Implements libMesh::Surface.

Definition at line 151 of file plane.C.

References _point, std::abs(), normal(), and libMesh::Real.

152 {
153  // Create a vector from the surface to point p;
154  const Point w = p - _point;
155 
156  // If the projection of that vector onto the
157  // plane's normal is 0 then the point is in
158  // the plane.
159  const Real proj = w * this->normal();
160 
161  if (std::abs(proj) < 1.e-10)
162  return true;
163 
164  return false;
165 }
Point _point
Definition: plane.h:144
double abs(double a)
const Point & normal() const
Definition: plane.h:139
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ surface_coords()

virtual Point libMesh::Surface::surface_coords ( const Point world_coords) const
inlinevirtualinherited
Returns
The Point world_coords in the surface's coordinate system. world_coords is in the world coordinate system. This method is not purely virtual, because there may be surfaces that do not have their own coordinate system. These simply do not have to override this method.

Reimplemented in libMesh::Sphere.

Definition at line 101 of file surface.h.

References libMesh::Surface::world_coords().

101 { return world_coords; }
virtual Point world_coords(const Point &surf_coords) const
Definition: surface.h:110

◆ unit_normal()

Point libMesh::Plane::unit_normal ( const Point p) const
overridevirtual
Returns
A unit vector normal to the surface at point p.

Implements libMesh::Surface.

Definition at line 184 of file plane.C.

References _normal.

185 {
186  return _normal;
187 }
Point _normal
Definition: plane.h:145

◆ world_coords()

virtual Point libMesh::Surface::world_coords ( const Point surf_coords) const
inlinevirtualinherited
Returns
The world (cartesian) coordinates for the surface coordinates surf_coords. This method is not purely virtual, because there may be surfaces that do not have an own coordinate system. These simply do not have to override this method.

Reimplemented in libMesh::Sphere.

Definition at line 110 of file surface.h.

Referenced by libMesh::Surface::surface_coords().

110 { return surf_coords; }

◆ xy_plane()

void libMesh::Plane::xy_plane ( const Real  zpos = 0.)

Creates an XY plane located at z=zpos.

Definition at line 94 of file plane.C.

References _normal, and _point.

95 {
96  const Point p (0., 0., zpos);
97  const Point n (0., 0., 1.);
98 
99  _point = p;
100  _normal = n;
101 }
Point _point
Definition: plane.h:144
Point _normal
Definition: plane.h:145

◆ xz_plane()

void libMesh::Plane::xz_plane ( const Real  ypos = 0.)

Creates an XZ plane located at y=ypos.

Definition at line 105 of file plane.C.

References _normal, and _point.

106 {
107  const Point p (0., ypos, 0.);
108  const Point n (0., 1., 0.);
109 
110  _point = p;
111  _normal = n;
112 }
Point _point
Definition: plane.h:144
Point _normal
Definition: plane.h:145

◆ yz_plane()

void libMesh::Plane::yz_plane ( const Real  xpos = 0.)

Creates an YZ plane located at x=xpos.

Definition at line 116 of file plane.C.

References _normal, and _point.

117 {
118  const Point p (xpos, 0., 0.);
119  const Point n (1., 0., 0.);
120 
121  _point = p;
122  _normal = n;
123 }
Point _point
Definition: plane.h:144
Point _normal
Definition: plane.h:145

Member Data Documentation

◆ _normal

Point libMesh::Plane::_normal
private

◆ _point

Point libMesh::Plane::_point
private

The plane is defined by a point and a normal.

Definition at line 144 of file plane.h.

Referenced by above_surface(), closest_point(), create_from_point_normal(), create_from_three_points(), get_planar_point(), on_surface(), Plane(), xy_plane(), xz_plane(), and yz_plane().


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