#ifndef DUST3D_CENTRIPETAL_CATMULL_ROM_SPLINE_H #define DUST3D_CENTRIPETAL_CATMULL_ROM_SPLINE_H #include #include class CentripetalCatmullRomSpline { public: struct SplineNode { int source = -1; QVector3D position; }; CentripetalCatmullRomSpline(bool isClosed); void addPoint(int source, const QVector3D &position, bool isKnot); bool interpolate(); const std::vector &splineNodes(); private: std::vector m_splineNodes; std::vector m_splineKnots; bool m_isClosed = false; bool interpolateClosed(); bool interpolateOpened(); float atKnot(float t, const QVector3D &p0, const QVector3D &p1); void interpolateSegment(std::vector &knots, size_t from, size_t to); }; #endif