/******************************************************************************* * Copyright (c) 2021, Bayerische Motoren Werke Aktiengesellschaft (BMW AG) * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ * * SPDX-License-Identifier: EPL-2.0 *******************************************************************************/ //----------------------------------------------------------------------------- /** @file spline.h */ //----------------------------------------------------------------------------- #ifndef MANTLEAPI_COMMON_SPLINE_H #define MANTLEAPI_COMMON_SPLINE_H #include #include #include #include #include #include using namespace units; namespace units { UNIT_ADD(jerk, meters_per_second_cubed, meters_per_second_cubed, mps_cu, compound_unit>>) namespace category { typedef base_unit, std::ratio<0>, std::ratio<-3>> jerk_unit; } UNIT_ADD_CATEGORY_TRAIT(jerk) UNIT_ADD(jerk_acceleration, meters_per_second_to_the_power_of_four, meters_per_second_to_the_power_of_four, mps_pow4, compound_unit>>) namespace category { typedef base_unit, std::ratio<0>, std::ratio<-4>> jerk_acceleration_unit; } UNIT_ADD_CATEGORY_TRAIT(jerk_acceleration) } // namespace units namespace mantle_api { template struct SplineSegment { Vec3 a; Vec3 b; Vec3 c; Vec3 d; }; template ::value>> struct SplineSection { Time start_time{0}; Time end_time{0}; /// @brief Represents the polynomial. /// /// The tuple stores in format \f$[a_3, a_2, a_1, a_0]\f$ for a polynomial in form /// \f[ /// P(x) = \sum_{i=0}^{3} a_{i} x^{i} = a_3 x^3 + a_2 x^2 + a_1 x + a_0 /// \f] std::tuple>>>, unit_t>>>, unit_t>>, unit_t> polynomial{ unit_t>>>(0), unit_t>>>(0), unit_t>>(0), unit_t(0)}; }; /// @brief Equality comparison for SplineSection. template ::value>> inline bool operator==(const SplineSection& lhs, const SplineSection& rhs) noexcept { return lhs.start_time == rhs.start_time && lhs.end_time == rhs.end_time && IsEqual(std::get<0>(lhs.polynomial), std::get<0>(rhs.polynomial)) && IsEqual(std::get<1>(lhs.polynomial), std::get<1>(rhs.polynomial)) && IsEqual(std::get<2>(lhs.polynomial), std::get<2>(rhs.polynomial)) && IsEqual(std::get<3>(lhs.polynomial), std::get<3>(rhs.polynomial)); } } // namespace mantle_api #endif // MANTLEAPI_COMMON_SPLINE_H