| 1 | #pragma once |
| 2 | |
| 3 | #include <math/seadVector.h> |
| 4 | |
| 5 | namespace al { |
| 6 | |
| 7 | class BezierCurve { |
| 8 | public: |
| 9 | BezierCurve(); |
| 10 | |
| 11 | void set(const sead::Vector3f& start, const sead::Vector3f& startHandle, |
| 12 | const sead::Vector3f& endHandle, const sead::Vector3f& end); |
| 13 | f32 calcLength(f32 startParam, f32 endParam, s32 stepCount) const; |
| 14 | void calcPos(sead::Vector3f* pos, f32 param) const; |
| 15 | void calcVelocity(sead::Vector3f* vel, f32 param) const; |
| 16 | f32 calcDeltaLength(f32 param) const; |
| 17 | f32 calcCurveParam(f32 distance) const; |
| 18 | f32 calcNearestParam(const sead::Vector3f& pos, f32 interval) const; |
| 19 | f32 calcNearestLength(f32* param, const sead::Vector3f& pos, f32 max, f32 interval) const; |
| 20 | void calcNearestPos(sead::Vector3f* nearest, const sead::Vector3f& pos, f32 interval) const; |
| 21 | void calcStartPos(sead::Vector3f* pos) const; |
| 22 | void calcCtrlPos1(sead::Vector3f* pos) const; |
| 23 | void calcCtrlPos2(sead::Vector3f* pos) const; |
| 24 | void calcEndPos(sead::Vector3f* pos) const; |
| 25 | |
| 26 | f32 getLength() const { return mDistance; } |
| 27 | |
| 28 | private: |
| 29 | sead::Vector3f mStart = sead::Vector3f::zero; |
| 30 | sead::Vector3f mControlPoint1 = sead::Vector3f::zero; |
| 31 | sead::Vector3f mControlPoint2 = sead::Vector3f::zero; |
| 32 | sead::Vector3f mControlPoint3 = sead::Vector3f::zero; // maybe end point? |
| 33 | f32 mDistance = 0; |
| 34 | }; |
| 35 | |
| 36 | } // namespace al |
| 37 | |