planeI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2018-2019 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
31 :
32  normal_(Zero),
33  origin_(Zero)
34 {}
35 
36 
37 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
38 
39 inline const Foam::vector& Foam::plane::normal() const
40 {
41  return normal_;
42 }
43 
44 
45 inline const Foam::point& Foam::plane::origin() const
46 {
47  return origin_;
48 }
49 
50 
52 {
53  return origin_;
54 }
55 
56 
57 inline const Foam::point& Foam::plane::refPoint() const
58 {
59  return origin_;
60 }
61 
62 
63 inline void Foam::plane::flip()
64 {
65  normal_ = -normal_;
66 }
67 
68 
70 {
71  return p - normal_*((p - origin_) & normal_);
72 }
73 
74 
75 inline Foam::scalar Foam::plane::distance(const point& p) const
76 {
77  return mag(signedDistance(p));
78 }
79 
80 
81 inline Foam::scalar Foam::plane::signedDistance(const point& p) const
82 {
83  return ((p - origin_) & normal_);
84 }
85 
86 
88 {
89  const scalar dist = signedDistance(p);
90 
91  return (dist < 0 ? BACK : FRONT);
92 }
93 
94 
95 inline int Foam::plane::sign(const point& p, const scalar tol) const
96 {
97  const scalar dist = signedDistance(p);
98 
99  return ((dist < -tol) ? -1 : (dist > tol) ? +1 : 0);
100 }
101 
102 
103 // * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
104 
105 inline bool Foam::operator==(const plane& a, const plane& b)
106 {
107  return (a.origin() == b.origin() && a.normal() == b.normal());
108 }
109 
110 
111 inline bool Foam::operator!=(const plane& a, const plane& b)
112 {
113  return !(a == b);
114 }
115 
116 
117 inline bool Foam::operator<(const plane& a, const plane& b)
118 {
119  return (a.origin() < b.origin());
120 }
121 
122 
123 // ************************************************************************* //
Foam::plane::distance
scalar distance(const point &p) const
Return distance (magnitude) from the given point to the plane.
Definition: planeI.H:75
Foam::plane::normal
const vector & normal() const
The plane unit normal.
Definition: planeI.H:39
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::plane::nearestPoint
point nearestPoint(const point &p) const
Return nearest point in the plane for the given point.
Definition: planeI.H:69
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::plane
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
Definition: plane.H:89
Foam::operator!=
bool operator!=(const eddy &a, const eddy &b)
Definition: eddy.H:239
Foam::plane::side
side
Side of the plane.
Definition: plane.H:94
Foam::constant::physicoChemical::b
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:27
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::plane::sign
int sign(const point &p, const scalar tol=SMALL) const
The sign for the side of the plane that the point is on.
Definition: planeI.H:95
Foam::plane::signedDistance
scalar signedDistance(const point &p) const
Return distance from the given point to the plane.
Definition: planeI.H:81
Foam::plane::flip
void flip()
Flip the plane by reversing the normal.
Definition: planeI.H:63
Foam::plane::origin
const point & origin() const
The plane base point.
Definition: planeI.H:45
Foam::Vector< scalar >
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::plane::refPoint
const point & refPoint() const
The plane base point (same as origin)
Definition: planeI.H:57
Foam::operator<
bool operator<(const IOstreamOption::versionNumber &a, const IOstreamOption::versionNumber &b) noexcept
Version A older than B.
Definition: IOstreamOption.H:398
Foam::plane::sideOfPlane
side sideOfPlane(const point &p) const
Return the side of the plane that the point is on.
Definition: planeI.H:87
Foam::plane::plane
plane()
Construct zero-initialised.
Definition: planeI.H:30