Virtual Testbed
Ship dynamics simulator for extreme conditions
core/hull.hh
1 #ifndef VTESTBED_CORE_HULL_HH
2 #define VTESTBED_CORE_HULL_HH
3 
4 #include <vtestbed/base/constants.hh>
5 #include <vtestbed/geometry/polyhedron.hh>
6 
7 namespace vtb {
8 
9  namespace core {
10 
11  template <class T>
12  class Hull: public vtb::geometry::Polyhedron<T,3> {
13 
14  private:
16 
17  public:
18  using typename base_type::scalar_type;
19  using typename base_type::vertex_type;
20  using typename base_type::face_type;
21  using typename base_type::vertex_array;
22  using typename base_type::face_array;
23  using typename base_type::size_type;
24  using typename base_type::index_type;
25  using typename base_type::box_type;
26  using typename base_type::triangle_type;
27  using typename base_type::triangle_array;
28  using typename base_type::bsp_tree;
29 
30  private:
31  scalar_type _mass = 0;
32 
33  public:
34 
35  using base_type::base_type;
36  using base_type::operator=;
37 
38  inline Hull(base_type&& rhs): base_type(std::move(rhs)) {}
39  inline Hull(const base_type& rhs): base_type(rhs) {}
40 
41  inline scalar_type mass() const { return this->_mass; }
42 
43  inline void mass(scalar_type rhs) {
44  if (rhs < 0) { throw std::invalid_argument("bad mass"); }
45  this->_mass = rhs;
46  }
47 
48  inline void
49  displacement(scalar_type rhs) {
51  }
52 
53  inline scalar_type
54  displacement() const {
55  return this->mass() / vtb::base::constants<T>::water_density();
56  }
57 
58  inline void
59  draught(scalar_type rhs) {
60  if (rhs < 0) { throw std::invalid_argument("bad draught"); }
61  auto level = this->bounds(2).min() + rhs;
62  this->displacement(this->signed_volume_below(2, level));
63  }
64 
65  };
66 
67  }
68 
69 }
70 
71 #endif // vim:filetype=cpp
static constexpr const T water_density()
Sea water density.
Definition: constants.hh:27
Main namespace.
Definition: convert.hh:9
Three-dimensional polyhedron.
Definition: polyhedron.hh:43