libMesh
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
libMesh::Plane Class Reference

This class defines a plane. More...

#include <plane.h>

Inheritance diagram for libMesh::Plane:
[legend]

Public Member Functions

 Plane ()
 Dummy Constructor.
 
 Plane (const Point &p, const Point &n)
 Constructs a plane containing point p with normal n.
 
 Plane (const Point &p0, const Point &p1, const Point &p2)
 Constructs a plane containing the three points.
 
 Plane (const Plane &other_plane)
 Copy-constructor.
 
 ~Plane ()
 Destructor.
 
void create_from_point_normal (const Point &p, const Point &n)
 Defines a plane containing point p with normal n.
 
void create_from_three_points (const Point &p0, const Point &p1, const Point &p2)
 Defines a plane intersecting the three points p0, p1, and p2.
 
void xy_plane (const Real zpos=0.)
 Creates an XY plane located at z=zpos.
 
void xz_plane (const Real ypos=0.)
 Creates an XZ plane located at y=ypos.
 
void yz_plane (const Real xpos=0.)
 Creates an YZ plane located at x=xpos.
 
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
 The plane is defined by a point and a normal.
 
Point _normal
 

Detailed Description

This class defines a plane.

Author
Benjamin S. Kirk
Date
2002

A geometric object representing a planar surface.

Definition at line 36 of file plane.h.

Constructor & Destructor Documentation

◆ Plane() [1/4]

libMesh::Plane::Plane ( )
default

Dummy Constructor.

◆ Plane() [2/4]

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

Constructs a plane containing point p with normal n.

Definition at line 34 of file plane.C.

36{
37 this->create_from_point_normal (p, n);
38}
void create_from_point_normal(const Point &p, const Point &n)
Defines a plane containing point p with normal n.
Definition plane.C:64

References create_from_point_normal().

◆ 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 42 of file plane.C.

45{
46 this->create_from_three_points (p0, p1, p2);
47}
void create_from_three_points(const Point &p0, const Point &p1, const Point &p2)
Defines a plane intersecting the three points p0, p1, and p2.
Definition plane.C:72

References create_from_three_points().

◆ Plane() [4/4]

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

Copy-constructor.

Definition at line 51 of file plane.C.

51 :
52 Surface()
53{
54 this->create_from_point_normal(other_plane._point,
55 other_plane._normal);
56}
Surface()=default
Constructor.

References _normal, _point, and create_from_point_normal().

◆ ~Plane()

libMesh::Plane::~Plane ( )
default

Destructor.

Does nothing at the moment.

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 121 of file plane.C.

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

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

Referenced by below_surface().

◆ 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 138 of file plane.C.

139{
140 return ( !this->above_surface (p) );
141}
virtual bool above_surface(const Point &p) const override
Definition plane.C:121

References above_surface().

◆ 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 163 of file plane.C.

164{
165 // Create a vector from the surface to point p;
166 const Point w = p - _point;
167
168 // The closest point in the plane to point p
169 // is in the negative normal direction
170 // a distance w (dot) p.
171 const Point cp = p - this->normal()*(w*this->normal());
172
173 return cp;
174}

References _point, and normal().

◆ 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 64 of file plane.C.

65{
66 _normal = n.unit();
67 _point = p;
68}
Point _normal
Definition plane.h:145
TypeVector< T > unit() const

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

Referenced by Plane(), and Plane().

◆ 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 72 of file plane.C.

75{
76 // Just use p0 for the point.
77 _point = p0;
78
79 const Point e0 = p1 - p0;
80 const Point e1 = p2 - p0;
81 const Point n = e0.cross(e1);
82
83 _normal = n.unit();
84}
TypeVector< typename CompareTypes< T, T2 >::supertype > cross(const TypeVector< T2 > &v) const

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

Referenced by Plane().

◆ get_planar_point()

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

Definition at line 183 of file plane.C.

184{
185 return _point;
186}

References _point.

◆ normal()

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

Definition at line 139 of file plane.h.

139{ return _normal; }

References _normal.

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

◆ 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 145 of file plane.C.

146{
147 // Create a vector from the surface to point p;
148 const Point w = p - _point;
149
150 // If the projection of that vector onto the
151 // plane's normal is 0 then the point is in
152 // the plane.
153 const Real proj = w * this->normal();
154
155 if (std::abs(proj) < 1.e-10)
156 return true;
157
158 return false;
159}

References _point, normal(), and libMesh::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.

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

References libMesh::Surface::world_coords().

◆ 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 178 of file plane.C.

179{
180 return _normal;
181}

References _normal.

◆ 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.

110{ return surf_coords; }

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

◆ xy_plane()

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

Creates an XY plane located at z=zpos.

Definition at line 88 of file plane.C.

89{
90 const Point p (0., 0., zpos);
91 const Point n (0., 0., 1.);
92
93 _point = p;
94 _normal = n;
95}

References _normal, and _point.

◆ xz_plane()

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

Creates an XZ plane located at y=ypos.

Definition at line 99 of file plane.C.

100{
101 const Point p (0., ypos, 0.);
102 const Point n (0., 1., 0.);
103
104 _point = p;
105 _normal = n;
106}

References _normal, and _point.

◆ yz_plane()

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

Creates an YZ plane located at x=xpos.

Definition at line 110 of file plane.C.

111{
112 const Point p (xpos, 0., 0.);
113 const Point n (1., 0., 0.);
114
115 _point = p;
116 _normal = n;
117}

References _normal, and _point.

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: