1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 Geometric class that creates a 2D plane and can return the intersection
29 point between a line and the plane.
34 \*---------------------------------------------------------------------------*/
40 #include "scalarList.H"
41 #include "dictionary.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 // Forward declaration of friend functions and operators
52 bool operator==(const plane&, const plane&);
53 bool operator!=(const plane&, const plane&);
54 Ostream& operator<<(Ostream&, const plane&);
57 /*---------------------------------------------------------------------------*\
58 Class plane Declaration
59 \*---------------------------------------------------------------------------*/
65 //- A direction and a reference point
74 ray(const point& refPoint, const vector& dir)
80 const point& refPoint() const
85 const vector& dir() const
103 // Private Member Functions
105 //- Calculates basePoint and normal vector given plane coefficients
106 void calcPntAndVec(const scalarList& C);
108 //- Calculates basePoint and normal vector given three points
109 //- Normal vector determined using right hand rule
122 //- Construct from normal vector through the origin
123 plane(const vector& normalVector);
125 //- Construct from normal vector and point in plane
126 plane(const point& basePoint, const vector& normalVector);
128 //- Construct from three points in plane
129 plane(const point& point1, const point& point2, const point& point3);
131 //- Construct from coefficients for the
132 // plane equation: ax + by + cz + d = 0
133 plane(const scalarList& C);
135 //- Construct from dictionary
136 plane(const dictionary& planeDict);
138 //- Construct from Istream. Assumes the base + normal notation.
144 //- Return plane normal
145 const vector& normal() const;
147 //- Return or return plane base point
148 const point& refPoint() const;
150 //- Return coefficients for the
151 // plane equation: ax + by + cz + d = 0
152 scalarList planeCoeffs() const;
154 //- Return nearest point in the plane for the given point
155 point nearestPoint(const point& p) const;
157 //- Return distance from the given point to the plane
158 scalar distance(const point& p) const;
160 //- Return cut coefficient for plane and line defined by
161 // origin and direction
162 scalar normalIntersect(const point& pnt0, const vector& dir) const;
164 //- Return cut coefficient for plane and ray
165 scalar normalIntersect(const ray& r) const
167 return normalIntersect(r.refPoint(), r.dir());
170 //- Return the cutting point between the plane and
171 // a line passing through the supplied points
172 template<class Point, class PointRef>
173 scalar lineIntersect(const line<Point, PointRef>& l) const
175 return normalIntersect(l.start(), l.vec());
178 //- Return the cutting line between this plane and another.
179 // Returned as direction vector and point line goes through.
180 ray planeIntersect(const plane&) const;
182 //- Return the cutting point between this plane and two other planes
183 point planePlaneIntersect(const plane&, const plane&) const;
188 friend bool operator==(const plane&, const plane&);
189 friend bool operator!=(const plane&, const plane&);
192 // IOstream Operators
194 //- Write plane properties
195 friend Ostream& operator<<(Ostream&, const plane&);
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 } // End namespace Foam
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 // ************************************************************************* //