File Coverage

/usr/local/lib/perl5/site_perl/5.26.1/x86_64-linux/CPP/geos.x/i/geos/geom/Triangle.h
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine n/a
pod n/a
total 3 3 100.0


line stmt bran cond sub pod time code
1             /**********************************************************************
2             *
3             * GEOS - Geometry Engine Open Source
4             * http://geos.osgeo.org
5             *
6             * Copyright (C) 2006 Refractions Research Inc.
7             *
8             * This is free software; you can redistribute and/or modify it under
9             * the terms of the GNU Lesser General Public Licence as published
10             * by the Free Software Foundation.
11             * See the COPYING file for more information.
12             *
13             **********************************************************************/
14              
15             #ifndef GEOS_GEOM_TRIANGLE_H
16             #define GEOS_GEOM_TRIANGLE_H
17              
18             #include
19             #include
20              
21             #include
22              
23             namespace geos {
24             namespace geom { // geos::geom
25              
26             /**
27             * \brief
28             * Represents a planar triangle, and provides methods for calculating various
29             * properties of triangles.
30             */
31             class GEOS_DLL Triangle {
32             public:
33             Coordinate p0, p1, p2;
34              
35 1           Triangle(const Coordinate& nP0, const Coordinate& nP1, const Coordinate& nP2)
36             :
37             p0(nP0),
38             p1(nP1),
39 1           p2(nP2)
40 1           {}
41              
42             /**
43             * The inCentre of a triangle is the point which is equidistant
44             * from the sides of the triangle. This is also the point at which the bisectors
45             * of the angles meet.
46             *
47             * @param resultPoint the point into which to write the inCentre of the triangle
48             */
49             void inCentre(Coordinate& resultPoint);
50              
51             /**
52             * Computes the circumcentre of a triangle. The circumcentre is the centre of
53             * the circumcircle, the smallest circle which encloses the triangle. It is
54             * also the common intersection point of the perpendicular bisectors of the
55             * sides of the triangle, and is the only point which has equal distance to
56             * all three vertices of the triangle.
57             *

58             * The circumcentre does not necessarily lie within the triangle. For example,
59             * the circumcentre of an obtuse isoceles triangle lies outside the triangle.
60             *

61             * This method uses an algorithm due to J.R.Shewchuk which uses normalization
62             * to the origin to improve the accuracy of computation. (See Lecture Notes
63             * on Geometric Robustness, Jonathan Richard Shewchuk, 1999).
64             *
65             * @param resultPoint the point into which to write the inCentre of the triangle
66             */
67             void circumcentre(Coordinate& resultPoint);
68              
69             private:
70              
71             /**
72             * Computes the determinant of a 2x2 matrix. Uses standard double-precision
73             * arithmetic, so is susceptible to round-off error.
74             *
75             * @param m00
76             * the [0,0] entry of the matrix
77             * @param m01
78             * the [0,1] entry of the matrix
79             * @param m10
80             * the [1,0] entry of the matrix
81             * @param m11
82             * the [1,1] entry of the matrix
83             * @return the determinant
84             */
85             double det(double m00 , double m01 , double m10 , double m11) const;
86              
87             };
88              
89              
90             } // namespace geos::geom
91             } // namespace geos
92              
93             //#ifdef GEOS_INLINE
94             //# include "geos/geom/Triangle.inl"
95             //#endif
96              
97             #endif // ndef GEOS_GEOM_TRIANGLE_H