Commit 39e5e9dc authored by Pierre Fernbach's avatar Pierre Fernbach
Browse files

Curve conversion: check if the degree of the input is <= 3

parent 1fd24d45
......@@ -36,6 +36,8 @@ Polynomial polynomial_from_curve(const typename Polynomial::curve_abc_t& curve)
/// \return the equivalent cubic bezier curve.
template <typename Bezier>
Bezier bezier_from_curve(const typename Bezier::curve_abc_t& curve) {
if(curve.degree() > 3)
throw std::invalid_argument("bezier_from_curve is only implemented for curves of degree <= 3.");
typedef typename Bezier::point_t point_t;
typedef typename Bezier::t_point_t t_point_t;
typedef typename Bezier::num_t num_t;
......@@ -68,6 +70,8 @@ Bezier bezier_from_curve(const typename Bezier::curve_abc_t& curve) {
/// \return the equivalent cubic hermite spline.
template <typename Hermite>
Hermite hermite_from_curve(const typename Hermite::curve_abc_t& curve) {
if(curve.degree() > 3)
throw std::invalid_argument("hermite_from_curve is only implemented for curves of degree <= 3.");
typedef typename Hermite::pair_point_tangent_t pair_point_tangent_t;
typedef typename Hermite::t_pair_point_tangent_t t_pair_point_tangent_t;
typedef typename Hermite::point_t point_t;
......@@ -91,4 +95,4 @@ Hermite hermite_from_curve(const typename Hermite::curve_abc_t& curve) {
return Hermite(control_points.begin(), control_points.end(), time_control_points);
}
} // namespace curves
#endif //_CLASS_CURVE_CONVERSION
\ No newline at end of file
#endif //_CLASS_CURVE_CONVERSION
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment