1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-12-01 15:35:47 +00:00
Aquaria/BBGE/Interpolators.h

53 lines
1.1 KiB
C
Raw Normal View History

2022-09-05 15:19:34 +00:00
#ifndef BBGE_INTERPOLATORS_H
#define BBGE_INTERPOLATORS_H
#include <algorithm> // std::pair
#include <vector>
#include "Vector.h"
class CosineInterpolator
{
public:
CosineInterpolator();
void clear();
void setPoints(const Vector *p, size_t n);
float operator()(float x) const;
void interpolateRange(float *ys, const float *xs, size_t n);
private:
std::vector<std::pair<float, float> > pxy;
};
#endif
class BSpline2D
{
public:
BSpline2D();
// # of control points on each axis
void resize(size_t cx, size_t cy, unsigned degx, unsigned degy, float tmin, float tmax);
void recalc(Vector *dst, size_t xres, size_t yres);
std::vector<Vector> controlpoints;
inline Vector& controlpoint(size_t x, size_t y)
{
return controlpoints[y * _cpx + x];
}
inline size_t ctrlX() const { return _cpx; }
inline size_t ctrlY() const { return _cpy; }
inline unsigned degX() const { return _degx; }
inline unsigned degY() const { return _degy; }
private:
size_t _cpx, _cpy; // # of control points
unsigned _degx, _degy;
float _tmin, _tmax;
std::vector<float> knotsX, knotsY;
};