Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Jason Chemin
curves
Commits
edf6cbc9
Commit
edf6cbc9
authored
Aug 14, 2019
by
JasonChmn
Committed by
Pierre Fernbach
Sep 03, 2019
Browse files
[python binding] Edit name of all curves of dimension 3 / delete bezier dimension 6
parent
b6633721
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
python/curves_python.cpp
View file @
edf6cbc9
This diff is collapsed.
Click to expand it.
python/test/test.py
View file @
edf6cbc9
...
...
@@ -6,10 +6,12 @@ from numpy.linalg import norm
#from curves import ( serialize_polynomial, deserialize_polynomial, serialize_piecewise_polynomial_curve, deserialize_piecewise_polynomial_curve )
from
curves
import
(
bezier3
,
bezier6
,
bezier_from_hermite
,
bezier_from_polynomial
,
cubic_hermite_spline
,
curve_constraints
,
exact_cubic
,
hermite_from_bezier
,
hermite_from_polynomial
,
piecewise_bezier3_curve
,
piecewise_bezier6_curve
,
piecewise_cubic_hermite_curve
,
piecewise_polynomial_curve
,
polynomial
,
polynomial_from_bezier
,
polynomial_from_hermite
)
from
curves
import
(
bezier_from_hermite
,
bezier_from_polynomial
,
hermite_from_polynomial
,
hermite_from_bezier
,
polynomial_from_hermite
,
polynomial_from_bezier
,
cubic_hermite_spline3
,
curve_constraints3
,
exact_cubic3
,
bezier3
,
piecewise_bezier3_curve
,
piecewise_cubic_hermite3_curve
,
piecewise_polynomial3_curve
,
polynomial3
)
#import curves
...
...
@@ -30,10 +32,8 @@ class TestCurves(unittest.TestCase):
self
.
assertTrue
(
norm
(
a
(
t
)
-
matrix
([
1.
,
2.
,
3.
]).
T
)
<
__EPS
)
t
+=
0.1
waypoints
=
matrix
([[
1.
,
2.
,
3.
],
[
4.
,
5.
,
6.
]]).
transpose
()
waypoints6
=
matrix
([[
1.
,
2.
,
3.
,
7.
,
5.
,
5.
],
[
4.
,
5.
,
6.
,
4.
,
5.
,
6.
]]).
transpose
()
time_waypoints
=
matrix
([
0.
,
1.
]).
transpose
()
# Create bezier6 and bezier3
a6
=
bezier6
(
waypoints6
)
a
=
bezier3
(
waypoints
,
0.
,
3.
)
# Test : Degree, min, max, derivate
#self.print_str(("test 1")
...
...
@@ -71,7 +71,7 @@ class TestCurves(unittest.TestCase):
self
.
assertTrue
(
norm
(
prim0
(
t
)
-
prim1
(
t
*
3
)
/
3.
)
<
__EPS
)
self
.
assertTrue
((
prim
(
0
)
==
matrix
([
0.
,
0.
,
0.
])).
all
())
# testing bezier with constraints
c
=
curve_constraints
()
c
=
curve_constraints
3
()
c
.
init_vel
=
matrix
([
0.
,
1.
,
1.
]).
transpose
()
c
.
end_vel
=
matrix
([
0.
,
1.
,
1.
]).
transpose
()
c
.
init_acc
=
matrix
([
0.
,
1.
,
-
1.
]).
transpose
()
...
...
@@ -88,12 +88,6 @@ class TestCurves(unittest.TestCase):
b
=
bezier3
()
b
.
loadFromText
(
"serialization_curve.test"
)
self
.
assertTrue
((
a
(
0.4
)
==
b
(
0.4
)).
all
())
# Test serialization : Bezier 6
a6
.
saveAsText
(
"serialization_curve.test"
)
b6
=
bezier6
()
b6
.
loadFromText
(
"serialization_curve.test"
)
self
.
assertTrue
((
a6
(
0.4
)
==
b6
(
0.4
)).
all
())
os
.
remove
(
"serialization_curve.test"
)
return
...
...
@@ -102,8 +96,8 @@ class TestCurves(unittest.TestCase):
# - Functions : constructor, min, max, derivate, serialize, deserialize
waypoints_0
=
matrix
([[
0.
,
0.
,
0.
],
[
0.
,
0.
,
0.
]]).
transpose
()
waypoints
=
matrix
([[
1.
,
2.
,
3.
],
[
4.
,
5.
,
6.
]]).
transpose
()
a
=
polynomial
(
waypoints
)
# Defined on [0.,1.]
a
=
polynomial
(
waypoints
,
-
1.
,
3.
)
# Defined on [-1.,3.]
a
=
polynomial
3
(
waypoints
)
# Defined on [0.,1.]
a
=
polynomial
3
(
waypoints
,
-
1.
,
3.
)
# Defined on [-1.,3.]
a
.
min
()
a
.
max
()
a
(
0.4
)
...
...
@@ -113,7 +107,7 @@ class TestCurves(unittest.TestCase):
self
.
assertTrue
((
a
.
derivate
(
0.4
,
1
)
==
a_derivated
(
0.4
)).
all
())
# Test serialization
a
.
saveAsText
(
"serialization_curve.test"
)
b
=
polynomial
()
b
=
polynomial
3
()
b
.
loadFromText
(
"serialization_curve.test"
)
self
.
assertTrue
((
a
(
0.4
)
==
b
(
0.4
)).
all
())
os
.
remove
(
"serialization_curve.test"
)
...
...
@@ -123,7 +117,7 @@ class TestCurves(unittest.TestCase):
points
=
matrix
([[
1.
,
2.
,
3.
],
[
4.
,
5.
,
6.
]]).
transpose
()
tangents
=
matrix
([[
1.
,
2.
,
3.
],
[
4.
,
5.
,
6.
]]).
transpose
()
time_points
=
matrix
([
0.
,
1.
]).
transpose
()
a
=
cubic_hermite_spline
(
points
,
tangents
,
time_points
)
a
=
cubic_hermite_spline
3
(
points
,
tangents
,
time_points
)
a
.
min
()
a
.
max
()
a
(
0.4
)
...
...
@@ -131,7 +125,7 @@ class TestCurves(unittest.TestCase):
a
.
derivate
(
0.4
,
2
)
# Test serialization
a
.
saveAsText
(
"serialization_curve.test"
)
b
=
cubic_hermite_spline
()
b
=
cubic_hermite_spline
3
()
b
.
loadFromText
(
"serialization_curve.test"
)
self
.
assertTrue
((
a
(
0.4
)
==
b
(
0.4
)).
all
())
os
.
remove
(
"serialization_curve.test"
)
...
...
@@ -143,10 +137,10 @@ class TestCurves(unittest.TestCase):
waypoints0
=
matrix
([[
0.
,
0.
,
0.
]]).
transpose
()
waypoints1
=
matrix
([[
1.
,
1.
,
1.
]]).
transpose
()
waypoints2
=
matrix
([[
1.
,
1.
,
1.
],
[
1.
,
1.
,
1.
]]).
transpose
()
pol0
=
polynomial
(
waypoints0
,
0.
,
0.1
)
a
=
polynomial
(
waypoints1
,
0.
,
1.
)
b
=
polynomial
(
waypoints2
,
1.
,
3.
)
pc
=
piecewise_polynomial_curve
(
a
)
pol0
=
polynomial
3
(
waypoints0
,
0.
,
0.1
)
a
=
polynomial
3
(
waypoints1
,
0.
,
1.
)
b
=
polynomial
3
(
waypoints2
,
1.
,
3.
)
pc
=
piecewise_polynomial
3
_curve
(
a
)
pc
.
add_curve
(
b
)
pc
.
min
()
pc
.
max
()
...
...
@@ -157,7 +151,7 @@ class TestCurves(unittest.TestCase):
pc
.
is_continuous
(
1
)
# Test serialization
pc
.
saveAsText
(
"serialization_pc.test"
)
pc_test
=
piecewise_polynomial_curve
()
pc_test
=
piecewise_polynomial
3
_curve
()
pc_test
.
loadFromText
(
"serialization_pc.test"
)
self
.
assertTrue
((
pc
(
0.4
)
==
pc_test
(
0.4
)).
all
())
os
.
remove
(
"serialization_pc.test"
)
...
...
@@ -186,29 +180,6 @@ class TestCurves(unittest.TestCase):
os
.
remove
(
"serialization_pc.test"
)
return
def
test_piecewise_bezier6_curve
(
self
):
# To test :
# - Functions : constructor, min, max, derivate, add_curve, is_continuous
waypoints
=
matrix
([[
1.
,
2.
,
3.
,
7.
,
5.
,
5.
],
[
4.
,
5.
,
6.
,
4.
,
5.
,
6.
]]).
transpose
()
a
=
bezier6
(
waypoints
,
0.
,
1.
)
b
=
bezier6
(
waypoints
,
1.
,
2.
)
pc
=
piecewise_bezier6_curve
(
a
)
pc
.
add_curve
(
b
)
pc
.
min
()
pc
.
max
()
pc
(
0.4
)
self
.
assertTrue
((
pc
.
derivate
(
0.4
,
0
)
==
pc
(
0.4
)).
all
())
pc
.
derivate
(
0.4
,
2
)
pc
.
is_continuous
(
0
)
pc
.
is_continuous
(
1
)
# Test serialization
pc
.
saveAsText
(
"serialization_pc.test"
)
pc_test
=
piecewise_bezier6_curve
()
pc_test
.
loadFromText
(
"serialization_pc.test"
)
self
.
assertTrue
((
pc
(
0.4
)
==
pc_test
(
0.4
)).
all
())
os
.
remove
(
"serialization_pc.test"
)
return
def
test_piecewise_cubic_hermite_curve
(
self
):
# To test :
# - Functions : constructor, min, max, derivate, add_curve, is_continuous
...
...
@@ -216,9 +187,9 @@ class TestCurves(unittest.TestCase):
tangents
=
matrix
([[
1.
,
2.
,
3.
],
[
4.
,
5.
,
6.
]]).
transpose
()
time_points0
=
matrix
([
0.
,
1.
]).
transpose
()
time_points1
=
matrix
([
1.
,
2.
]).
transpose
()
a
=
cubic_hermite_spline
(
points
,
tangents
,
time_points0
)
b
=
cubic_hermite_spline
(
points
,
tangents
,
time_points1
)
pc
=
piecewise_cubic_hermite_curve
(
a
)
a
=
cubic_hermite_spline
3
(
points
,
tangents
,
time_points0
)
b
=
cubic_hermite_spline
3
(
points
,
tangents
,
time_points1
)
pc
=
piecewise_cubic_hermite
3
_curve
(
a
)
pc
.
add_curve
(
b
)
pc
.
min
()
pc
.
max
()
...
...
@@ -229,7 +200,7 @@ class TestCurves(unittest.TestCase):
pc
.
is_continuous
(
1
)
# Test serialization
pc
.
saveAsText
(
"serialization_pc.test"
)
pc_test
=
piecewise_cubic_hermite_curve
()
pc_test
=
piecewise_cubic_hermite
3
_curve
()
pc_test
.
loadFromText
(
"serialization_pc.test"
)
self
.
assertTrue
((
pc
(
0.4
)
==
pc_test
(
0.4
)).
all
())
os
.
remove
(
"serialization_pc.test"
)
...
...
@@ -240,7 +211,7 @@ class TestCurves(unittest.TestCase):
# - Functions : constructor, min, max, derivate, getNumberSplines, getSplineAt
waypoints
=
matrix
([[
1.
,
2.
,
3.
],
[
4.
,
5.
,
6.
]]).
transpose
()
time_waypoints
=
matrix
([
0.
,
1.
]).
transpose
()
a
=
exact_cubic
(
waypoints
,
time_waypoints
)
a
=
exact_cubic
3
(
waypoints
,
time_waypoints
)
a
.
min
()
a
.
max
()
a
(
0.4
)
...
...
@@ -250,7 +221,7 @@ class TestCurves(unittest.TestCase):
a
.
getSplineAt
(
0
)
# Test serialization
a
.
saveAsText
(
"serialization_pc.test"
)
b
=
exact_cubic
()
b
=
exact_cubic
3
()
b
.
loadFromText
(
"serialization_pc.test"
)
self
.
assertTrue
((
a
(
0.4
)
==
b
(
0.4
)).
all
())
os
.
remove
(
"serialization_pc.test"
)
...
...
@@ -261,7 +232,7 @@ class TestCurves(unittest.TestCase):
# - Functions : constructor, min, max, derivate
waypoints
=
matrix
([[
1.
,
2.
,
3.
],
[
4.
,
5.
,
6.
]]).
transpose
()
time_waypoints
=
matrix
([
0.
,
1.
]).
transpose
()
c
=
curve_constraints
()
c
=
curve_constraints
3
()
c
.
init_vel
c
.
end_vel
c
.
init_acc
...
...
@@ -270,8 +241,8 @@ class TestCurves(unittest.TestCase):
c
.
end_vel
=
matrix
([
0.
,
1.
,
1.
]).
transpose
()
c
.
init_acc
=
matrix
([
0.
,
1.
,
1.
]).
transpose
()
c
.
end_acc
=
matrix
([
0.
,
1.
,
1.
]).
transpose
()
a
=
exact_cubic
(
waypoints
,
time_waypoints
)
a
=
exact_cubic
(
waypoints
,
time_waypoints
,
c
)
a
=
exact_cubic
3
(
waypoints
,
time_waypoints
)
a
=
exact_cubic
3
(
waypoints
,
time_waypoints
,
c
)
return
def
test_conversion_curves
(
self
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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