SOLA
Loading...
Searching...
No Matches
structure_helpers.h
1// Copyright 2023 The SOLA authors
2//
3// This file is part of DAISI.
4//
5// DAISI is free software: you can redistribute it and/or modify it under the terms of the GNU
6// General Public License as published by the Free Software Foundation; version 2.
7//
8// DAISI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
9// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
10// Public License for more details.
11//
12// You should have received a copy of the GNU General Public License along with DAISI. If not, see
13// <https://www.gnu.org/licenses/>.
14//
15// SPDX-License-Identifier: GPL-2.0-only
16
17#ifndef DAISI_UTILS_STRUCTURE_HELPERS_H_
18#define DAISI_UTILS_STRUCTURE_HELPERS_H_
19
20#include <ns3/vector.h>
21
22#include "solanet/serializer/serialize.h"
23
24template <class Archive> inline void serialize(Archive &archive, ns3::Vector2D &m) {
25 archive(m.x, m.y);
26}
27
28template <class Archive> inline void serialize(Archive &archive, ns3::Vector3D &m) {
29 archive(m.x, m.y);
30}
31
32inline ns3::Vector2D operator/(const ns3::Vector2D &vec, double d) {
33 return {vec.x / d, vec.y / d};
34}
35
36inline ns3::Vector2D operator*(const ns3::Vector2D &vec, double d) {
37 return {vec.x * d, vec.y * d};
38}
39
40inline ns3::Vector2D operator*(double d, const ns3::Vector2D &vec) { return vec * d; }
41
42inline ns3::Vector2D operator-=(ns3::Vector2D &vec1, const ns3::Vector2D &vec2) {
43 vec1.x = vec1.x - vec2.x;
44 vec1.y = vec1.y - vec2.y;
45 return vec1;
46}
47
48inline ns3::Vector2D operator+=(ns3::Vector2D &vec1, const ns3::Vector2D &vec2) {
49 vec1.x = vec1.x + vec2.x;
50 vec1.y = vec1.y + vec2.y;
51 return vec1;
52}
53
54inline ns3::Vector2D operator-(const ns3::Vector2D &vec) { return {-vec.x, -vec.y}; }
55
56namespace daisi::util {
57
58using Position = ns3::Vector2D;
59using Velocity = ns3::Vector2D;
60using Acceleration = ns3::Vector2D;
61using Dimensions = ns3::Vector3D;
62using Duration = double;
63using Distance = double;
64struct Pose {
65 Pose() = default;
66 Pose(Position position_m, double orientation_rad)
67 : position(position_m), orientation(orientation_rad) {}
68 explicit Pose(Position position_m) : position(position_m) {}
69
70 Position position;
71 double orientation = 0.0;
72 SERIALIZE(position, orientation);
73};
74
75} // namespace daisi::util
76
77#endif // DAISI_UTILS_STRUCTURE_HELPERS_H_
Definition structure_helpers.h:64