labplot  2.8.2
About: LabPlot is an application for plotting and analysis of 2D and 3D functions and data. It is a complete rewrite of LabPlot1 and lacks in the first release a lot of features available in the predecessor. On the other hand, the GUI and the usability is more superior.
  Fossies Dox: labplot-2.8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

nsl_geom_linesim.h
Go to the documentation of this file.
1 /***************************************************************************
2  File : nsl_geom_linesim.h
3  Project : LabPlot
4  Description : NSL geometry line simplification functions
5  --------------------------------------------------------------------
6  Copyright : (C) 2016 by Stefan Gerlach (stefan.gerlach@uni.kn)
7 
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  * This program is distributed in the hope that it will be useful, *
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20  * GNU General Public License for more details. *
21  * *
22  * You should have received a copy of the GNU General Public License *
23  * along with this program; if not, write to the Free Software *
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
25  * Boston, MA 02110-1301 USA *
26  * *
27  ***************************************************************************/
28 
29 /*
30  TODO:
31  * accelerate Visvalingam-Whyatt
32  * calculate error statistics
33  * more algorithms: Jenks, Zhao-Saalfeld
34  * non-parametric version of Visvalingam-Whyatt, Opheim and Lang
35 */
36 
37 #ifndef NSL_GEOM_LINESIM_H
38 #define NSL_GEOM_LINESIM_H
39 
40 #include <stdlib.h>
41 
42 #define NSL_GEOM_LINESIM_TYPE_COUNT 10
46 extern const char* nsl_geom_linesim_type_name[];
47 
48 /*********** error calculation functions *********/
49 
50 /* calculates positional error (sum of perpendicular distance per point)
51  of simplified set (given by index[])
52 */
53 double nsl_geom_linesim_positional_error(const double xdata[], const double ydata[], const size_t n, const size_t index[]);
54 /* calculates positional error (sum of squared perpendicular distance per point)
55  of simplified set (given by index[])
56 */
57 double nsl_geom_linesim_positional_squared_error(const double xdata[], const double ydata[], const size_t n, const size_t index[]);
58 
59 /* calculates area error (area between original and simplified data per point)
60  of simplified set (given by index[])
61 */
62 double nsl_geom_linesim_area_error(const double xdata[], const double ydata[], const size_t n, const size_t index[]);
63 
64 /* calculates tolerance by using diagonal distance of all data point clip area
65  divided by n */
66 double nsl_geom_linesim_clip_diag_perpoint(const double xdata[], const double ydata[], const size_t n);
67 
68 /* calculates tolerance from clip area
69  divided by n */
70 double nsl_geom_linesim_clip_area_perpoint(const double xdata[], const double ydata[], const size_t n);
71 
72 /* calculates tolerance from average distance of following point
73  divided by n */
74 double nsl_geom_linesim_avg_dist_perpoint(const double xdata[], const double ydata[], const size_t n);
75 
76 /*********** simplification algorithms *********/
77 
78 /* Douglas-Peucker line simplification
79  xdata, ydata: data points
80  n: number of points
81  tol: minimum tolerance (perpendicular distance)
82  index: index of reduced points
83  -> returns final number of points
84 */
85 size_t nsl_geom_linesim_douglas_peucker(const double xdata[], const double ydata[], const size_t n, const double tol, size_t index[]);
86 size_t nsl_geom_linesim_douglas_peucker_auto(const double xdata[], const double ydata[], const size_t n, size_t index[]);
87 /* Douglas-Peucker variant resulting in a given number of points
88  xdata, ydata: data points
89  n: number of points
90  nout: number of output points
91  index: index of reduced points
92  -> returns perpendicular distance of last added point (upper limit for all remaining points)
93 */
94 double nsl_geom_linesim_douglas_peucker_variant(const double xdata[], const double ydata[], const size_t n, const size_t nout, size_t index[]);
95 
96 /* simple n-th point line simplification
97  n: number of points
98  step: step size
99  index: index of reduced points
100  -> returns final number of points
101 */
102 size_t nsl_geom_linesim_nthpoint(const size_t n, const int step, size_t index[]);
103 
104 /* radial distance line simplification
105  xdata, ydata: data points
106  n: number of points
107  tol: tolerance (radius)
108  index: index of reduced points
109  -> returns final number of points
110 */
111 size_t nsl_geom_linesim_raddist(const double xdata[], const double ydata[], const size_t n, const double tol, size_t index[]);
112 size_t nsl_geom_linesim_raddist_auto(const double xdata[], const double ydata[], const size_t n, size_t index[]);
113 
114 /* perpendicular distance line simplification
115  xdata, ydata: data points
116  n: number of points
117  tol: tolerance (perp. distance)
118  index: index of reduced points
119  -> returns final number of points
120 */
121 size_t nsl_geom_linesim_perpdist(const double xdata[], const double ydata[], const size_t n, const double tol, size_t index[]);
122 size_t nsl_geom_linesim_perpdist_auto(const double xdata[], const double ydata[], const size_t n, size_t index[]);
123 /* repeat perpendicular distance line simplification
124  repeat: number of repeats
125  */
126 size_t nsl_geom_linesim_perpdist_repeat(const double xdata[], const double ydata[], const size_t n, const double tol, const size_t repeat, size_t index[]);
127 
128 /* line simplification by nearest neigbor interpolation (idea from xmgrace)
129  xdata, ydata: data points
130  n: number of points
131  tol: tolerance (perp. distance)
132  index: index of reduced points
133  -> returns final number of points
134 */
135 size_t nsl_geom_linesim_interp(const double xdata[], const double ydata[], const size_t n, const double tol, size_t index[]);
136 size_t nsl_geom_linesim_interp_auto(const double xdata[], const double ydata[], const size_t n, size_t index[]);
137 
138 /* Visvalingam-Whyatt line simplification
139  xdata, ydata: data points
140  n: number of points
141  tol: tolerance (area)
142  index: index of reduced points
143  -> returns final number of points
144 */
145 size_t nsl_geom_linesim_visvalingam_whyatt(const double xdata[], const double ydata[], const size_t n, const double tol, size_t index[]);
146 size_t nsl_geom_linesim_visvalingam_whyatt_auto(const double xdata[], const double ydata[], const size_t n, size_t index[]);
147 
148 /* Reumann-Witkam line simplification
149  xdata, ydata: data points
150  n: number of points
151  tol: tolerance (perp. distance)
152  index: index of reduced points
153  -> returns final number of points
154 */
155 size_t nsl_geom_linesim_reumann_witkam(const double xdata[], const double ydata[], const size_t n, const double tol, size_t index[]);
156 size_t nsl_geom_linesim_reumann_witkam_auto(const double xdata[], const double ydata[], const size_t n, size_t index[]);
157 
158 /* Opheim line simplification
159  xdata, ydata: data points
160  n: number of points
161  mintol: minimum tolerance (to define ray)
162  maxtol: maximum tolerance (to define next key)
163  index: index of reduced points
164  -> returns final number of points
165 */
166 size_t nsl_geom_linesim_opheim(const double xdata[], const double ydata[], const size_t n, const double mintol, const double maxtol, size_t index[]);
167 size_t nsl_geom_linesim_opheim_auto(const double xdata[], const double ydata[], const size_t n, size_t index[]);
168 
169 /* Lang line simplification
170  xdata, ydata: data points
171  n: number of points
172  tol: minimum tolerance (perpendicular distance)
173  region: search region (number of points)
174  index: index of reduced points
175  -> returns final number of points
176 */
177 size_t nsl_geom_linesim_lang(const double xdata[], const double ydata[], const size_t n, const double tol, const size_t region, size_t index[]);
178 size_t nsl_geom_linesim_lang_auto(const double xdata[], const double ydata[], const size_t n, size_t index[]);
179 
180 #endif /* NSL_GEOM_LINESIM_H */
double nsl_geom_linesim_positional_error(const double xdata[], const double ydata[], const size_t n, const size_t index[])
double nsl_geom_linesim_positional_squared_error(const double xdata[], const double ydata[], const size_t n, const size_t index[])
size_t nsl_geom_linesim_raddist_auto(const double xdata[], const double ydata[], const size_t n, size_t index[])
double nsl_geom_linesim_clip_area_perpoint(const double xdata[], const double ydata[], const size_t n)
size_t nsl_geom_linesim_douglas_peucker_auto(const double xdata[], const double ydata[], const size_t n, size_t index[])
size_t nsl_geom_linesim_raddist(const double xdata[], const double ydata[], const size_t n, const double tol, size_t index[])
size_t nsl_geom_linesim_perpdist_auto(const double xdata[], const double ydata[], const size_t n, size_t index[])
size_t nsl_geom_linesim_reumann_witkam_auto(const double xdata[], const double ydata[], const size_t n, size_t index[])
double nsl_geom_linesim_avg_dist_perpoint(const double xdata[], const double ydata[], const size_t n)
size_t nsl_geom_linesim_opheim_auto(const double xdata[], const double ydata[], const size_t n, size_t index[])
size_t nsl_geom_linesim_interp(const double xdata[], const double ydata[], const size_t n, const double tol, size_t index[])
size_t nsl_geom_linesim_perpdist(const double xdata[], const double ydata[], const size_t n, const double tol, size_t index[])
double nsl_geom_linesim_clip_diag_perpoint(const double xdata[], const double ydata[], const size_t n)
size_t nsl_geom_linesim_douglas_peucker(const double xdata[], const double ydata[], const size_t n, const double tol, size_t index[])
size_t nsl_geom_linesim_reumann_witkam(const double xdata[], const double ydata[], const size_t n, const double tol, size_t index[])
size_t nsl_geom_linesim_visvalingam_whyatt_auto(const double xdata[], const double ydata[], const size_t n, size_t index[])
size_t nsl_geom_linesim_opheim(const double xdata[], const double ydata[], const size_t n, const double mintol, const double maxtol, size_t index[])
size_t nsl_geom_linesim_lang_auto(const double xdata[], const double ydata[], const size_t n, size_t index[])
size_t nsl_geom_linesim_nthpoint(const size_t n, const int step, size_t index[])
size_t nsl_geom_linesim_lang(const double xdata[], const double ydata[], const size_t n, const double tol, const size_t region, size_t index[])
double nsl_geom_linesim_douglas_peucker_variant(const double xdata[], const double ydata[], const size_t n, const size_t nout, size_t index[])
const char * nsl_geom_linesim_type_name[]
size_t nsl_geom_linesim_interp_auto(const double xdata[], const double ydata[], const size_t n, size_t index[])
nsl_geom_linesim_type
@ nsl_geom_linesim_type_opheim
@ nsl_geom_linesim_type_douglas_peucker_variant
@ nsl_geom_linesim_type_perpdist
@ nsl_geom_linesim_type_lang
@ nsl_geom_linesim_type_interp
@ nsl_geom_linesim_type_visvalingam_whyatt
@ nsl_geom_linesim_type_raddist
@ nsl_geom_linesim_type_nthpoint
@ nsl_geom_linesim_type_douglas_peucker
@ nsl_geom_linesim_type_reumann_witkam
size_t nsl_geom_linesim_visvalingam_whyatt(const double xdata[], const double ydata[], const size_t n, const double tol, size_t index[])
double nsl_geom_linesim_area_error(const double xdata[], const double ydata[], const size_t n, const size_t index[])
size_t nsl_geom_linesim_perpdist_repeat(const double xdata[], const double ydata[], const size_t n, const double tol, const size_t repeat, size_t index[])