Virtual Testbed
Ship dynamics simulator for extreme conditions
src
vtestbed
geometry
bezier_curve.hh
1
#ifndef VTESTBED_GEOMETRY_BEZIER_CURVE_HH
2
#define VTESTBED_GEOMETRY_BEZIER_CURVE_HH
3
4
#include <vtestbed/base/blitz.hh>
5
6
namespace
vtb
{
7
8
namespace
geometry {
9
10
template
<
class
T,
int
N>
11
class
Bezier_curve
{
12
13
public
:
14
using
value_type = Vertex<T,N>;
15
using
reference = value_type&;
16
using
const_reference =
const
value_type&;
17
using
container_type
=
std::vector<value_type>
;
18
using
size_type = size_t;
19
20
private
:
21
const
container_type
& _values;
22
23
public
:
24
25
inline
explicit
26
Bezier_curve
(
const
container_type
& values):
27
_values(values) {}
28
32
inline
value_type
33
operator()
(T t)
const
{
34
T t1 = T{1} - t;
35
auto
p = this->_values;
36
int
n = p.size()-1;
37
for
(
int
j=1; j<=n; ++j) {
38
for
(
int
i=0; i<=n-j; ++i) {
39
p[i] = p[i]*t1 + p[i+1]*t;
40
}
41
}
42
return
p[0];
43
}
44
45
};
46
47
}
48
49
}
50
51
#endif // vim:filetype=cpp
vtb
Main namespace.
Definition:
convert.hh:9
std::vector< value_type >
vtb::geometry::Bezier_curve
Definition:
bezier_curve.hh:11
vtb::geometry::Bezier_curve::operator()
value_type operator()(T t) const
Definition:
bezier_curve.hh:33
Generated by
1.8.15