CARLA
DataStructs.h
Go to the documentation of this file.
1 #pragma once
2 #include <vector>
3 #include <array>
4 #include <functional>
5 
6 namespace MeshReconstruction
7 {
8  struct Vec3
9  {
10  double x, y, z;
11 
12  Vec3 operator+(Vec3 const &o) const
13  {
14  return {x + o.x, y + o.y, z + o.z};
15  }
16 
17  Vec3 operator-(Vec3 const &o) const
18  {
19  return {x - o.x, y - o.y, z - o.z};
20  }
21 
22  Vec3 operator*(double c) const
23  {
24  return {c * x, c * y, c * z};
25  }
26 
27  double Norm() const
28  {
29  return sqrt(x * x + y * y + z * z);
30  }
31 
32  Vec3 Normalized() const
33  {
34  auto n = Norm();
35  return {x / n, y / n, z / n};
36  }
37  };
38 
39  struct Rect3
40  {
43  };
44 
45  using Triangle = std::array<int, 3>;
46 
47  struct Mesh
48  {
49  std::vector<Vec3> vertices;
50  std::vector<Triangle> triangles;
51  std::vector<Vec3> vertexNormals;
52  };
53 
54  using Fun3s = std::function<double(Vec3 const &)>;
55  using Fun3v = std::function<Vec3(Vec3 const &)>;
56 }
std::vector< Vec3 > vertices
Definition: DataStructs.h:49
std::vector< Vec3 > vertexNormals
Definition: DataStructs.h:51
Vec3 Normalized() const
Definition: DataStructs.h:32
std::function< double(Vec3 const &)> Fun3s
Definition: DataStructs.h:54
Vec3 operator*(double c) const
Definition: DataStructs.h:22
Vec3 operator+(Vec3 const &o) const
Definition: DataStructs.h:12
std::function< Vec3(Vec3 const &)> Fun3v
Definition: DataStructs.h:55
std::array< int, 3 > Triangle
Definition: DataStructs.h:45
std::vector< Triangle > triangles
Definition: DataStructs.h:50
Vec3 operator-(Vec3 const &o) const
Definition: DataStructs.h:17
double Norm() const
Definition: DataStructs.h:27