Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pierre Fernbach
curves
Commits
39e5e9dc
Commit
39e5e9dc
authored
May 04, 2020
by
Pierre Fernbach
Browse files
Curve conversion: check if the degree of the input is <= 3
parent
1fd24d45
Changes
1
Hide whitespace changes
Inline
Side-by-side
include/curves/curve_conversion.h
View file @
39e5e9dc
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment