Mercurial Hosting > traffic-intelligence
comparison trajectorymanagement/src/HuMetric.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 HUMETRIC_H_ | |
2 #define HUMETRIC_H_ | |
3 | |
4 #include "EuclideanMetric.h" | |
5 | |
6 #include "TrajectoryExceptions.h" | |
7 | |
8 /** | |
9 * HuMetric class. | |
10 * | |
11 * The Hu metric measures the normalized distance between two trajectories. | |
12 */ | |
13 template<typename Tr, typename To> | |
14 class HuMetric: public Metric<Tr, To> | |
15 { | |
16 public: | |
17 /** | |
18 * Constructor. | |
19 */ | |
20 HuMetric() | |
21 { | |
22 euclideanMetric = new EuclideanMetric<Tr,To> (); | |
23 } | |
24 | |
25 /** | |
26 * Destructor. | |
27 */ | |
28 ~HuMetric() | |
29 { | |
30 delete euclideanMetric; | |
31 } | |
32 | |
33 /** | |
34 * Compute normalized distance between two trajectories. | |
35 * | |
36 * @param[in] a input trajectory | |
37 * @param[in] b input trajectory | |
38 * @param[out] result distance between two trajectories | |
39 */ | |
40 void distance(const Trajectory<Tr> *a, const Trajectory<Tr> *b, To &result, unsigned int nbOfPoints = std::numeric_limits<unsigned int>::max()) | |
41 { | |
42 To diff = To(0); | |
43 | |
44 euclideanMetric->distance(a, b, diff, nbOfPoints); | |
45 | |
46 diff /= To(a->size() * 2); | |
47 | |
48 result = diff; | |
49 } | |
50 | |
51 private: | |
52 /** | |
53 * Pointer to EuclideanMetric class. | |
54 */ | |
55 Metric<Tr, To> *euclideanMetric; | |
56 }; | |
57 | |
58 #endif /* HUMETRIC_H_ */ |