Simulant
21.12-1292
A portable game engine for Windows, OSX, Linux, Dreamcast, and PSP
simulant
math
bezier_curve.h
1
#pragma once
2
3
#include <cmath>
4
#include <array>
5
#include "vec3.h"
6
#include "quaternion.h"
7
#include "../generic/range_value.h"
8
9
namespace
smlt
{
10
11
struct
BezierCurve
{
12
13
// Creates a degree-three bezier curve (cubic)
14
BezierCurve
(
const
Vec3
& p0,
const
Vec3
& p1,
const
Vec3
& p2,
const
Vec3
& p3):
15
p0_(p0),
16
p1_(p1),
17
p2_(p2),
18
p3_(p3) {
19
bezierPoints_.clear();
20
bezierPoints_.push_back(p0_);
21
bezierPoints_.push_back(p1_);
22
bezierPoints_.push_back(p2_);
23
bezierPoints_.push_back(p3_);
24
}
25
26
// Returns the position and rotation of a point on the curve at a given time.
27
// Please note that 't' will be clamped between 0 and 1.
28
Vec3
calc_bezier_point(
const
RangeValue<0, 1>
t)
const
;
29
30
private
:
31
std::vector<Vec3> bezierPoints_;
32
33
Vec3
p0_, p1_, p2_, p3_;
34
35
};
36
}
smlt::Vec3
Definition:
vec3.h:25
smlt
Definition:
animation.cpp:25
smlt::BezierCurve
Definition:
bezier_curve.h:11
smlt::RangeValue
Definition:
range_value.h:24
Generated by
1.8.20