Virtual Testbed
Ship dynamics simulator for extreme conditions
coons_surface.hh
1 #ifndef VTESTBED_GEOMETRY_COONS_SURFACE_HH
2 #define VTESTBED_GEOMETRY_COONS_SURFACE_HH
3 
4 #include <algorithm>
5 #include <vector>
6 
7 namespace vtb {
8 
9  namespace geometry {
10 
11  template <class T, class Curve>
12  class Coons_surface {
13 
14  public:
15  using curve_type = Curve;
16  using value_type = typename curve_type::value_type;
17  using size_type = size_t;
18 
19  private:
20  curve_type _c0, _c1, _d0, _d1;
21  T _u_min{0}, _u_max{1};
22  T _v_min{0}, _v_max{1};
23 
24  public:
25 
26  inline explicit
28  const curve_type& c0,
29  const curve_type& c1,
30  const curve_type& d0,
31  const curve_type& d1
32  ): _c0(c0), _c1(c1), _d0(d0), _d1(d1) {}
33 
34  inline value_type
35  operator()(T u, T v) const {
36  T u1 = T{1} - u;
37  T v1 = T{1} - v;
38  value_type c = _c0(u)*v1 + _c1(u)*v;
39  value_type d = _d0(v)*u1 + _d1(v)*u;
40  value_type p00 = _c0(_u_min);
41  value_type p01 = _c0(_u_max);
42  value_type p10 = _c1(_u_min);
43  value_type p11 = _c1(_u_max);
44  value_type cd = p00*u1*v1 + p01*u*v1 + p10*u1*v + p11*u*v;
45  return c + d - cd;
46  }
47 
48  inline void
49  u_range(T min, T max) {
50  this->_u_min = min;
51  this->_u_max = max;
52  }
53 
54  inline size_type
55  max_size_u() const {
56  return std::max(this->_c0.size(), this->_c1.size());
57  }
58 
59  inline size_type
60  max_size_v() const {
61  return std::max(this->_d0.size(), this->_d1.size());
62  }
63 
64  };
65 
66  }
67 
68 }
69 
70 
71 #endif // vim:filetype=cpp
Main namespace.
Definition: convert.hh:9