GLC_lib  2.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
glc_geomtools.h
Go to the documentation of this file.
1 /****************************************************************************
2 
3  This file is part of the GLC-lib library.
4  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
5  http://glc-lib.sourceforge.net
6 
7  GLC-lib is free software; you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11 
12  GLC-lib is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with GLC-lib; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21 *****************************************************************************/
22 
24 
25 #ifndef GLC_GEOMTOOLS_H_
26 #define GLC_GEOMTOOLS_H_
27 
28 #include <QVector>
29 #include <QList>
30 #include <QPointF>
31 
32 #include "glc_vector3d.h"
33 #include "glc_line3d.h"
34 #include "glc_plane.h"
35 
36 #include "../geometry/glc_mesh.h"
37 
38 #include "../glc_config.h"
39 
40 namespace glc
41 {
42  const double defaultPrecision= 0.01;
43  GLC_LIB_EXPORT extern double comparedPrecision;
45 
47 
48 
49  GLC_LIB_EXPORT bool polygon2DIsConvex(const QList<GLC_Point2d>& vertices);
50 
52  GLC_LIB_EXPORT bool polygonIsConvex(QList<GLuint>* pIndexList, const QList<float>& bulkList);
53 
55 
59  GLC_LIB_EXPORT QVector<GLC_Point2d> findIntersection(const GLC_Point2d&, const GLC_Point2d&, const GLC_Point2d&, const GLC_Point2d&);
60 
62  GLC_LIB_EXPORT bool isIntersected(const GLC_Point2d&, const GLC_Point2d&, const GLC_Point2d&, const GLC_Point2d&);
63 
66 
68 
72  GLC_LIB_EXPORT QVector<double> findIntersection(const double&, const double&, const double&, const double&);
73 
75  GLC_LIB_EXPORT bool segmentInCone(const GLC_Point2d&, const GLC_Point2d&, const GLC_Point2d&, const GLC_Point2d&);
76 
78  GLC_LIB_EXPORT bool isDiagonal(const QList<GLC_Point2d>&, const int, const int);
79 
81  GLC_LIB_EXPORT void triangulate(QList<GLC_Point2d>&, QList<int>&, QList<int>&);
82 
84  GLC_LIB_EXPORT bool isCounterclockwiseOrdered(const QList<GLC_Point2d>&);
85 
87 
88  GLC_LIB_EXPORT void triangulatePolygon(QList<GLuint>*, const QList<float>&);
89 
91 
93  GLC_LIB_EXPORT bool lineIntersectPlane(const GLC_Line3d& line, const GLC_Plane& plane, GLC_Point3d* pPoint);
94 
96  GLC_LIB_EXPORT GLC_Point3d project(const GLC_Point3d& point, const GLC_Line3d& line);
97 
99  inline GLC_Point3d midPoint(const GLC_Point3d& point1, const GLC_Point3d point2)
100  {return point1 + (point2 - point1) * 0.5;}
101 
104  {return GLC_Vector2d(-vect.y(), vect.x());}
105 
107  GLC_LIB_EXPORT double pointLineDistance(const GLC_Point3d& point, const GLC_Line3d& line);
108 
110  GLC_LIB_EXPORT bool pointsAreCollinear(const GLC_Point3d& p1, const GLC_Point3d& p2, const GLC_Point3d& p3);
111 
112  GLC_LIB_EXPORT bool compare(double p1, double p2);
113 
114  GLC_LIB_EXPORT bool compare(double p1, double p2, double accuracy);
115 
116  GLC_LIB_EXPORT bool compareAngle(double p1, double p2);
117 
118  GLC_LIB_EXPORT bool compare(const GLC_Vector3d& v1, const GLC_Vector3d& v2);
119 
120  GLC_LIB_EXPORT bool compare(const GLC_Vector3d& v1, const GLC_Vector3d& v2, double accuracy);
121 
122  GLC_LIB_EXPORT bool compare(const GLC_Vector2d& v1, const GLC_Vector2d& v2);
123 
124  GLC_LIB_EXPORT bool compare(const GLC_Vector2d& v1, const GLC_Vector2d& v2, double accuracy);
125 
126  GLC_LIB_EXPORT bool compare(const QPointF& v1, const QPointF& v2);
127 
128  GLC_LIB_EXPORT bool compare(const QPointF& v1, const QPointF& v2, double accuracy);
129 
130  GLC_LIB_EXPORT double round(double value);
131 
132  GLC_LIB_EXPORT double round(double value, double accuracy);
133 
134  GLC_LIB_EXPORT QPointF round(const QPointF& point);
135 
136  GLC_LIB_EXPORT QPointF round(const QPointF& point, double accuracy);
137 
139 
140  GLC_LIB_EXPORT GLC_Vector2d round(const GLC_Vector2d& vector, double accuracy);
141 
143 
144  GLC_LIB_EXPORT GLC_Vector3d round(const GLC_Vector3d& vector, double accuracy);
145 
147  GLC_LIB_EXPORT bool pointInPolygon(const GLC_Point2d& point, const QList<GLC_Point2d>& polygon);
148 
150  GLC_LIB_EXPORT double zeroTo2PIAngle(double angle);
151 
153  GLC_LIB_EXPORT QList<GLC_Point2d> polygonIn2d(QList<GLC_Point3d> polygon3d);
154 
156  GLC_LIB_EXPORT QList<GLC_Point2d> normalyzePolygon(const QList<GLC_Point2d>& polygon);
157 
159 
160 }
161 
162 #endif /*GLC_GEOMTOOLS_H_*/

©2005-2013 Laurent Ribon