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/>.
33 \*---------------------------------------------------------------------------*/
39 #include "PointHitTemplate.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 // Forward declaration of classes
53 // Forward declaration of friend functions and operators
55 template<class Point, class PointRef> class line;
57 template<class Point, class PointRef>
58 inline Istream& operator>>(Istream&, line<Point, PointRef>&);
60 template<class Point, class PointRef>
61 inline Ostream& operator<<(Ostream&, const line<Point, PointRef>&);
64 /*---------------------------------------------------------------------------*\
65 Class line Declaration
66 \*---------------------------------------------------------------------------*/
68 template<class Point, class PointRef>
80 //- Construct from two points
81 inline line(const Point& start, const Point& end);
83 //- Construct from Istream
84 inline line(Istream&);
91 //- Return first vertex
92 inline PointRef start() const;
94 //- Return second vertex
95 inline PointRef end() const;
100 //- Return centre (centroid)
101 inline Point centre() const;
103 //- Return scalar magnitude
104 inline scalar mag() const;
106 //- Return start-end vector
107 inline Point vec() const;
109 //- Return nearest distance to line from a given point
110 // If the nearest point is on the line, return a hit
111 PointHit<Point> nearestDist(const Point& p) const;
113 //- Return nearest distance from line to line. Returns distance
114 // and sets both points (one on *this, one on the provided
118 const line<Point, const Point&>& edge,
126 friend Istream& operator>> <Point, PointRef>
132 friend Ostream& operator<< <Point, PointRef>
140 //- 2D specialisation
142 scalar line<point2D, const point2D&>::nearestDist
144 const line<point2D, const point2D&>& edge,
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 } // End namespace Foam
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 // ************************************************************************* //