-
Notifications
You must be signed in to change notification settings - Fork 8
/
Bezier_test.py
59 lines (46 loc) · 1.75 KB
/
Bezier_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from Bezier import CubicBezier, QuadBezier
print("Creating a Bezier curve object")
curve = CubicBezier(p0x=-1, p0y=0, p1x=-0.5, p1y=0.5, p2x=0.5, p2y=-0.5, p3x=1, p3y=0)
curve.plot()
print("Adding an obstacle")
curve.add_obstacle(x=0, y= 0, radius= 0.3)
curve.plot()
print("Adding an additional random obstacle")
curve.add_random_obstacle(min_x=-1, max_x=1, min_y=-0.5, max_y=0.5, min_radius=0.05, max_radius=0.5)
curve.plot()
print("Optimizing arc-length")
curve.optimize_l()
curve.plot()
print("Optimizing curvature")
curve.optimize_k()
curve.plot()
print("Simultaniously optimizing arc-length and curvature")
curve.optimize()
curve.plot()
print("Re-initializing the Bezier curve")
curve.clear()
print("Creating a random Bezier curve")
curve.random(min=-1,max=1)
curve.plot()
print("Adding random obstacles")
for i in range(0,3):
curve.add_random_obstacle(min_x=min(curve.p0.x,curve.p3.x), max_x=max(curve.p0.x,curve.p3.x),
min_y=min(curve.p0.y,curve.p3.y), max_y=max(curve.p0.y,curve.p3.y),
min_radius=0.05, max_radius=0.5)
curve.plot()
print("Simultaniously optimizing arc-length and curvature")
curve.optimize()
curve.plot()
print("Creating a random quadratic Bezier curve")
curve = QuadBezier()
curve.random(min=-1,max=1)
curve.plot()
print("Adding random obstacles")
for i in range(0,3):
curve.add_random_obstacle(min_x=min(curve.p0.x,curve.p2.x), max_x=max(curve.p0.x,curve.p2.x),
min_y=min(curve.p0.y,curve.p2.y), max_y=max(curve.p0.y,curve.p2.y),
min_radius=0.05, max_radius=0.5)
curve.plot()
print("Simultaniously optimizing arc-length and curvature")
curve.optimize()
curve.plot()