comparison trajectorymanagement/src/EuclideanMetric.h @ 1159:e1e7acef8eab

moved trajectory management library into Traffic Intelligence
author Nicolas Saunier <nicolas.saunier@polymtl.ca>
date Mon, 22 Feb 2021 22:09:35 -0500
parents
children
comparison
equal deleted inserted replaced
1158:7eb972942f22 1159:e1e7acef8eab
1 #ifndef EUCLIDIANMETRIC_H_
2 #define EUCLIDIANMETRIC_H_
3
4 #include "SquaredEuclideanMetric.h"
5 #include "TrajectoryExceptions.h"
6
7 /**
8 * EuclideanMetric class.
9 *
10 * The Euclidean metric measures the distance between two trajectories.
11 */
12 template<typename Tr, typename To>
13 class EuclideanMetric: public Metric<Tr, To>
14 {
15 public:
16 /**
17 * Constructor.
18 */
19 EuclideanMetric()
20 {
21 squaredEuclideanMetric = new SquaredEuclideanMetric<Tr, To> ();
22 }
23
24 /**
25 * Destructor.
26 */
27 ~EuclideanMetric()
28 {
29 delete squaredEuclideanMetric;
30 }
31
32 /**
33 * Compute distance between two trajectories.
34 *
35 * @param[in] a input trajectory
36 * @param[in] b input trajectory
37 * @param[out] result distance between two trajectories
38 */
39 void distance(const Trajectory<Tr> *a, const Trajectory<Tr> *b, To &result, unsigned int nbOfPoints = std::numeric_limits<unsigned int>::max())
40 {
41 To diff = To(0);
42
43 squaredEuclideanMetric->distance(a, b, diff, nbOfPoints);
44
45 diff = sqrt(diff);
46
47 result = diff;
48 }
49
50 private:
51 /**
52 * Pointer to a SquaredEuclideanMetric class.
53 */
54 Metric<Tr, To> *squaredEuclideanMetric;
55 };
56
57 #endif /* EUCLIDIANMETRIC_H_ */