(C++)  1.0.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
BezierSpline.hh
1 #ifndef GRAIL_BEZIER_SPLINE_H
2 #define GRAIL_BEZIER_SPLINE_H
3 
4 #include "Curve.hh"
5 #include "../../libs/vector2/vector2.h"
6 
7 namespace grail
8 {
9  namespace curves
10  {
11  class BezierSpline final : public Curve
12  {
13  public:
14  BezierSpline(const std::vector<Vector2>& points, const std::vector<Vector2>& tangents, float epsilon = 0.001f);
15  BezierSpline(std::vector<Vector2>&& points, std::vector<Vector2>&& tangents, float epsilon = 0.001f);
16 
17  virtual float Sample(float argument) const override;
18 
19  std::vector<Vector2>& GetPoints();
20  const std::vector<Vector2>& GetPoints() const;
21 
22  std::vector<Vector2>& GetTangents();
23  const std::vector<Vector2>& GetTangents() const;
24 
25  CurveTypeId GetTypeId() const override;
26 
27  private:
28  Vector2 BezierInterpolation(const std::size_t beginIndex, const std::size_t endIndex, float t) const;
29 
30  std::vector<Vector2> points{};
31  std::vector<Vector2> tangents{};
32  float epsilon = 0.0f;
33 
34  float leftGradient = 0.0f;
35  float leftIntercept = 0.0f;
36  float rightGradient = 0.0f;
37  float rightIntercept = 0.0f;
38  };
39  }
40 }
41 
42 #endif // GRAIL_BEZIER_SPLINE_H
Definition: BezierSpline.hh:12
virtual float Sample(float argument) const override
Sample - User-defined method which processes provided value (currently vector of values - multidemens...
Definition: BezierSpline.cpp:29
The Curve class - Defines objects transforming one value into the other.
Definition: Curve.hh:17