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
184902f6
Commit
184902f6
authored
Jul 08, 2019
by
JasonChmn
Committed by
Pierre Fernbach
Sep 03, 2019
Browse files
[curves] rename order_ to degree_
parent
32bd5feb
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/curves/bezier_curve.h
View file @
184902f6
...
...
@@ -101,7 +101,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Safe, Point>
bezier_curve
(
const
bezier_curve
&
other
)
:
t_min_
(
other
.
t_min_
),
t_max_
(
other
.
t_max_
),
mult_T_
(
other
.
mult_T_
),
size_
(
other
.
size_
),
order
_
(
other
.
order
_
),
bernstein_
(
other
.
bernstein_
),
control_points_
(
other
.
control_points_
)
degree
_
(
other
.
degree
_
),
bernstein_
(
other
.
bernstein_
),
control_points_
(
other
.
control_points_
)
{}
///\brief Destructor
...
...
include/curves/cubic_hermite_spline.h
View file @
184902f6
...
...
@@ -47,7 +47,7 @@ struct cubic_hermite_spline : public curve_abc<Time, Numeric, Safe, Point>
///
template
<
typename
In
>
cubic_hermite_spline
(
In
PairsBegin
,
In
PairsEnd
,
const
vector_time_t
&
time_control_points
)
:
order
_
(
3
)
:
degree
_
(
3
)
{
// Check size of pairs container.
std
::
size_t
const
size
(
std
::
distance
(
PairsBegin
,
PairsEnd
));
...
...
@@ -66,7 +66,7 @@ struct cubic_hermite_spline : public curve_abc<Time, Numeric, Safe, Point>
}
cubic_hermite_spline
(
const
cubic_hermite_spline
&
other
)
:
t_min_
(
other
.
t_min_
),
t_max_
(
other
.
t_max_
),
size_
(
other
.
size_
),
order
_
(
other
.
order
_
),
:
t_min_
(
other
.
t_min_
),
t_max_
(
other
.
t_max_
),
size_
(
other
.
size_
),
degree
_
(
other
.
degree
_
),
control_points_
(
other
.
control_points_
),
time_control_points_
(
other
.
time_control_points_
),
duration_splines_
(
other
.
duration_splines_
)
{}
...
...
@@ -163,20 +163,20 @@ struct cubic_hermite_spline : public curve_abc<Time, Numeric, Safe, Point>
/// Polynom \f$p(t) \in [t_0, t_1]\f$ becomes \f$p(\alpha) \in [0, 1]\f$
/// and \f$p(\alpha) = p((t-t_0)/(t_1-t_0))\f$.
/// \param t : time when to evaluate the curve.
/// \param
order
_derivative : Order of derivate of cubic hermite spline (set value to 0 if you do not want derivate)
/// \param
degree
_derivative : Order of derivate of cubic hermite spline (set value to 0 if you do not want derivate)
/// \return point corresponding \f$p(t)\f$ on spline at time t or its derivate order N \f$\frac{d^Np(t)}{dt^N}\f$.
///
Point
evalCubicHermiteSpline
(
const
Numeric
t
,
std
::
size_t
order
_derivative
)
const
Point
evalCubicHermiteSpline
(
const
Numeric
t
,
std
::
size_t
degree
_derivative
)
const
{
const
std
::
size_t
id
=
findInterval
(
t
);
// ID is on the last control point
if
(
id
==
size_
-
1
)
{
if
(
order
_derivative
==
0
)
if
(
degree
_derivative
==
0
)
{
return
control_points_
.
back
().
first
;
}
else
if
(
order
_derivative
==
1
)
else
if
(
degree
_derivative
==
1
)
{
return
control_points_
.
back
().
second
;
}
...
...
@@ -200,11 +200,11 @@ struct cubic_hermite_spline : public curve_abc<Time, Numeric, Safe, Point>
const
Time
alpha
=
(
t
-
t0
)
/
dt
;
assert
(
0.
<=
alpha
&&
alpha
<=
1.
&&
"alpha must be in [0,1]"
);
Numeric
h00
,
h10
,
h01
,
h11
;
evalCoeffs
(
alpha
,
h00
,
h10
,
h01
,
h11
,
order
_derivative
);
evalCoeffs
(
alpha
,
h00
,
h10
,
h01
,
h11
,
degree
_derivative
);
//std::cout << "for val t="<<t<<" alpha="<<alpha<<" coef : h00="<<h00<<" h10="<<h10<<" h01="<<h01<<" h11="<<h11<<std::endl;
Point
p_
=
(
h00
*
Pair0
.
first
+
h10
*
dt
*
Pair0
.
second
+
h01
*
Pair1
.
first
+
h11
*
dt
*
Pair1
.
second
);
// if derivative, divide by dt^
order
_derivative
for
(
std
::
size_t
i
=
0
;
i
<
order
_derivative
;
i
++
)
// if derivative, divide by dt^
degree
_derivative
for
(
std
::
size_t
i
=
0
;
i
<
degree
_derivative
;
i
++
)
{
p_
/=
dt
;
}
...
...
@@ -224,34 +224,34 @@ struct cubic_hermite_spline : public curve_abc<Time, Numeric, Safe, Point>
/// \param h10 : variable to store value of coefficient.
/// \param h01 : variable to store value of coefficient.
/// \param h11 : variable to store value of coefficient.
/// \param
order
_derivative : order of derivative.
/// \param
degree
_derivative : order of derivative.
///
static
void
evalCoeffs
(
const
Numeric
t
,
Numeric
&
h00
,
Numeric
&
h10
,
Numeric
&
h01
,
Numeric
&
h11
,
std
::
size_t
order
_derivative
)
static
void
evalCoeffs
(
const
Numeric
t
,
Numeric
&
h00
,
Numeric
&
h10
,
Numeric
&
h01
,
Numeric
&
h11
,
std
::
size_t
degree
_derivative
)
{
Numeric
t_square
=
t
*
t
;
Numeric
t_cube
=
t_square
*
t
;
if
(
order
_derivative
==
0
)
if
(
degree
_derivative
==
0
)
{
h00
=
2
*
t_cube
-
3
*
t_square
+
1.
;
h10
=
t_cube
-
2
*
t_square
+
t
;
h01
=
-
2
*
t_cube
+
3
*
t_square
;
h11
=
t_cube
-
t_square
;
}
else
if
(
order
_derivative
==
1
)
else
if
(
degree
_derivative
==
1
)
{
h00
=
6
*
t_square
-
6
*
t
;
h10
=
3
*
t_square
-
4
*
t
+
1.
;
h01
=
-
6
*
t_square
+
6
*
t
;
h11
=
3
*
t_square
-
2
*
t
;
}
else
if
(
order
_derivative
==
2
)
else
if
(
degree
_derivative
==
2
)
{
h00
=
12
*
t
-
6.
;
h10
=
6
*
t
-
4.
;
h01
=
-
12
*
t
+
6.
;
h11
=
6
*
t
-
2.
;
}
else
if
(
order
_derivative
==
3
)
else
if
(
degree
_derivative
==
3
)
{
h00
=
12.
;
h10
=
6.
;
...
...
@@ -368,7 +368,7 @@ struct cubic_hermite_spline : public curve_abc<Time, Numeric, Safe, Point>
/// Number of control points (pairs).
std
::
size_t
size_
;
/// Degree (Cubic so degree 3)
std
::
size_t
order
_
;
std
::
size_t
degree
_
;
/*Attributes*/
};
...
...
include/curves/polynomial.h
View file @
184902f6
...
...
@@ -53,7 +53,7 @@ struct polynomial : public curve_abc<Time, Numeric, Safe, Point>
/// \param max : UPPER bound on interval definition of the curve.
polynomial
(
const
coeff_t
&
coefficients
,
const
time_t
min
,
const
time_t
max
)
:
curve_abc_t
(),
coefficients_
(
coefficients
),
dim_
(
Dim
),
order
_
(
coefficients_
.
cols
()
-
1
),
t_min_
(
min
),
t_max_
(
max
)
coefficients_
(
coefficients
),
dim_
(
Dim
),
degree
_
(
coefficients_
.
cols
()
-
1
),
t_min_
(
min
),
t_max_
(
max
)
{
safe_check
();
}
...
...
@@ -67,7 +67,7 @@ struct polynomial : public curve_abc<Time, Numeric, Safe, Point>
polynomial
(
const
T_Point
&
coefficients
,
const
time_t
min
,
const
time_t
max
)
:
curve_abc_t
(),
coefficients_
(
init_coeffs
(
coefficients
.
begin
(),
coefficients
.
end
())),
dim_
(
Dim
),
order
_
(
coefficients_
.
cols
()
-
1
),
t_min_
(
min
),
t_max_
(
max
)
dim_
(
Dim
),
degree
_
(
coefficients_
.
cols
()
-
1
),
t_min_
(
min
),
t_max_
(
max
)
{
safe_check
();
}
...
...
@@ -81,7 +81,7 @@ struct polynomial : public curve_abc<Time, Numeric, Safe, Point>
template
<
typename
In
>
polynomial
(
In
zeroOrderCoefficient
,
In
out
,
const
time_t
min
,
const
time_t
max
)
:
coefficients_
(
init_coeffs
(
zeroOrderCoefficient
,
out
)),
dim_
(
Dim
),
order
_
(
coefficients_
.
cols
()
-
1
),
t_min_
(
min
),
t_max_
(
max
)
dim_
(
Dim
),
degree
_
(
coefficients_
.
cols
()
-
1
),
t_min_
(
min
),
t_max_
(
max
)
{
safe_check
();
}
...
...
@@ -95,7 +95,7 @@ struct polynomial : public curve_abc<Time, Numeric, Safe, Point>
polynomial
(
const
polynomial
&
other
)
:
coefficients_
(
other
.
coefficients_
),
dim_
(
other
.
dim_
),
order
_
(
other
.
order
_
),
t_min_
(
other
.
t_min_
),
t_max_
(
other
.
t_max_
)
dim_
(
other
.
dim_
),
degree
_
(
other
.
degree
_
),
t_min_
(
other
.
t_min_
),
t_max_
(
other
.
t_max_
)
{}
...
...
@@ -130,7 +130,7 @@ struct polynomial : public curve_abc<Time, Numeric, Safe, Point>
time_t const dt (t-t_min_);
time_t cdt(1);
point_t currentPoint_ = point_t::Zero();
for(int i = 0; i <
order
_+1; ++i, cdt*=dt)
for(int i = 0; i <
degree
_+1; ++i, cdt*=dt)
currentPoint_ += cdt *coefficients_.col(i);
return currentPoint_;
}*/
...
...
@@ -146,8 +146,8 @@ struct polynomial : public curve_abc<Time, Numeric, Safe, Point>
throw
std
::
invalid_argument
(
"error in polynomial : time t to evaluate should be in range [Tmin, Tmax] of the curve"
);
}
time_t
const
dt
(
t
-
t_min_
);
point_t
h
=
coefficients_
.
col
(
order
_
);
for
(
int
i
=
(
int
)(
order
_
-
1
);
i
>=
0
;
i
--
)
point_t
h
=
coefficients_
.
col
(
degree
_
);
for
(
int
i
=
(
int
)(
degree
_
-
1
);
i
>=
0
;
i
--
)
{
h
=
dt
*
h
+
coefficients_
.
col
(
i
);
}
...
...
@@ -167,8 +167,8 @@ struct polynomial : public curve_abc<Time, Numeric, Safe, Point>
}
time_t
const
dt
(
t
-
t_min_
);
time_t
cdt
(
1
);
point_t
currentPoint_
=
point_t
::
Zero
(
dim_
);
for
(
int
i
=
(
int
)(
order
);
i
<
(
int
)(
order
_
+
1
);
++
i
,
cdt
*=
dt
)
point_t
currentPoint_
=
point_t
::
Zero
();
for
(
int
i
=
(
int
)(
order
);
i
<
(
int
)(
degree
_
+
1
);
++
i
,
cdt
*=
dt
)
{
currentPoint_
+=
cdt
*
coefficients_
.
col
(
i
)
*
fact
(
i
,
order
);
}
...
...
@@ -202,7 +202,7 @@ struct polynomial : public curve_abc<Time, Numeric, Safe, Point>
public:
coeff_t
coefficients_
;
//const
std
::
size_t
dim_
;
//const
std
::
size_t
order
_
;
//const
std
::
size_t
degree
_
;
//const
private:
time_t
t_min_
,
t_max_
;
...
...
tests/Main.cpp
View file @
184902f6
...
...
@@ -448,10 +448,10 @@ void BezierDerivativeCurveConstraintTest(bool& error)
std
::
string
errMsg1
(
"In test BezierDerivativeCurveConstraintTest, Error While checking checking degree of bezier curve :"
);
std
::
string
errMsg2
(
"In test BezierDerivativeCurveConstraintTest, Error While checking checking size of bezier curve :"
);
if
(
cf
.
order
_
!=
params
.
size
()
+
3
)
if
(
cf
.
degree
_
!=
params
.
size
()
+
3
)
{
error
=
true
;
std
::
cout
<<
errMsg1
<<
cf
.
order
_
<<
" ; "
<<
params
.
size
()
+
3
<<
std
::
endl
;
std
::
cout
<<
errMsg1
<<
cf
.
degree
_
<<
" ; "
<<
params
.
size
()
+
3
<<
std
::
endl
;
}
if
(
cf
.
size_
!=
params
.
size
()
+
4
)
{
...
...
@@ -1010,7 +1010,7 @@ void BezierSplitCurve(bool& error)
std
::
pair
<
bezier_curve_t
,
bezier_curve_t
>
cs
=
c
.
split
(
ts
);
// test on splitted curves :
if
(
!
((
c
.
order
_
==
cs
.
first
.
order
_
)
&&
(
c
.
order
_
==
cs
.
second
.
order
_
)
))
if
(
!
((
c
.
degree
_
==
cs
.
first
.
degree
_
)
&&
(
c
.
degree
_
==
cs
.
second
.
degree
_
)
))
{
error
=
true
;
std
::
cout
<<
"BezierSplitCurve, ERROR Degree of the splitted curve are not the same as the original curve"
<<
std
::
endl
;
...
...
Write
Preview
Supports
Markdown
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