-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPolyLine_Simplification.h
More file actions
59 lines (47 loc) · 1.5 KB
/
PolyLine_Simplification.h
File metadata and controls
59 lines (47 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* PolyLine_Simplification.h
*
* Created on: Aug 15, 2010
* Author: ptroja
*/
#ifndef POLYLINE_SIMPLIFICATION_H_
#define POLYLINE_SIMPLIFICATION_H_
#include <vector>
#include <valarray>
//===================================================================
// Definitions
//===================================================================
typedef double Scalar;
typedef std::valarray<double> PointBase;
class Point : public PointBase
{
public:
Point();
Point(const PointBase & va);
Point(double _x, double _y);
// Reuse assignment operators from base class
using PointBase::operator=;
};
class Vector : public PointBase
{
public:
Vector();
Vector(const PointBase & va);
// Reuse assignment operators from base class
using PointBase::operator=;
};
class Segment
{
public:
Point P0, P1;
};
// dot product (3D) which allows vector operations in arguments
#define dot(u,v) (((u)*(v)).sum())
#define norm2(v) dot((v),(v)) // norm2 = squared length of vector
#define norm(v) std::sqrt(norm2(v)) // norm = length of vector
#define d2(u,v) norm2((u)-(v)) // distance squared = norm2 of difference
#define d(u,v) norm((u)-(v)) // distance = norm of difference
void simplifyDP(const double tol, const Point* v, const int j, const int k, bool * mk);
unsigned int poly_simplify(const double tol, const std::vector<Point> & V, std::vector<Point> & sV);
double dist_Point_to_Segment(const Point & P, const Segment & S, Point & C);
#endif /* POLYLINE_SIMPLIFICATION_H_ */