44 #include "../../lib/bezier/BezierQuad.hpp" 82 float precision = 0.00001;
189 float resolution = 0.1f;
192 float duration, arc_length, triangle_length, straigth_length;
196 for (
int i = 0; i < 100 ; i++) {
210 triangle_length = (ctrl - pt0).length() + (pt1 - ctrl).length();
211 straigth_length = (pt1 - pt0).length();
214 float time_increment = duration / T;
215 float t = 0.0f + time_increment;
217 float sum_segments = 0.0f;
219 for (
int s = 0; s < (int)T; s++) {
221 sum_segments = (nextpt - p0).length() + sum_segments;
223 t = t + time_increment;
227 ut_assert_true((triangle_length >= arc_length) && (arc_length >= straigth_length)
228 && (fabsf(arc_length - sum_segments) < 1.
f));
242 float precision = 0.001f;
244 for (
int i = 0; i < 20; i++) {
250 float duration =
random(0.0
f, 100.0
f);
273 float s = rand() / (float)RAND_MAX;
274 return (min + s * (max - min));
#define ut_declare_test_c(test_function, test_class)
int test_bezierQuad(int argc, char *argv[])
Vector3_t getVelocity(const Tp t)
Tp getArcLength(const Tp resolution)
Base class to be used for unit tests.
virtual bool run_tests()
Override to run your unit tests.
int _tests_failed
The number of unit tests which failed.
bool _get_states_from_time()
void setBezFromVel(const Vector3_t &ctrl, const Vector3_t &vel0, const Vector3_t &vel1, const Tp duration=(Tp) 1)
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
void getStates(Vector3_t &point, Vector3_t &vel, Vector3_t &acc, const Tp t)
float random(float min, float max)
#define ut_assert_true(test)
To assert specifically to true.
constexpr _Tp min(_Tp a, _Tp b)
Vector3_t getPoint(const Tp t)
Return point on bezier point corresponding to time t.
Vector3< float > Vector3f
constexpr _Tp max(_Tp a, _Tp b)
#define ut_run_test(test)
Runs a single unit test.
#define ut_compare_float(message, v1, v2, precision)
Used to compare two float values within a unit test.
void setBezier(const Vector3_t &pt0, const Vector3_t &ctrl, const Vector3_t &pt1, Tp duration=(Tp) 1)
Set new bezier points and duration.