File tree Expand file tree Collapse file tree 1 file changed +2
-23
lines changed Expand file tree Collapse file tree 1 file changed +2
-23
lines changed Original file line number Diff line number Diff line change 1
1
defmodule SplinePath do
2
2
@ moduledoc """
3
3
This module defines methods to generate a spline path out of a waypoint path
4
+
5
+ Based on https://qroph.github.io/2018/07/30/smooth-paths-using-catmull-rom-splines.html
4
6
"""
5
7
alias BotManager.Math.Vector
6
8
@@ -31,29 +33,6 @@ alias BotManager.Math.Vector
31
33
|> List . flatten ( )
32
34
end
33
35
34
- # float t01 = pow(distance(p0, p1), alpha);
35
- # float t12 = pow(distance(p1, p2), alpha);
36
- # float t23 = pow(distance(p2, p3), alpha);
37
-
38
- # vec2 m1 = (1.0f - tension) *
39
- # (p2 - p1 + t12 * (
40
- # (p1 - p0) / t01 - (p2 - p0) / (t01 + t12)
41
- # )
42
- # );
43
- # vec2 m2 = (1.0f - tension) *
44
- # (p2 - p1 + t12 * ((p3 - p2) / t23 - (p3 - p1) / (t12 + t23)));
45
- #
46
- # Segment segment;
47
- # segment.a = 2.0f * (p1 - p2) + m1 + m2;
48
- # segment.b = -3.0f * (p1 - p2) - m1 - m1 - m2;
49
- # segment.c = m1;
50
- # segment.d = p1;
51
- #
52
- # vec2 point = segment.a * t * t * t +
53
- # segment.b * t * t +
54
- # segment.c * t +
55
- # segment.d;
56
-
57
36
defp build_points_for_spline ( [ p0 , p1 , p2 , p3 ] ) do
58
37
t01 = :math . pow ( Vector . distance ( p0 , p1 ) , @ alpha )
59
38
t12 = :math . pow ( Vector . distance ( p1 , p2 ) , @ alpha )
You can’t perform that action at this time.
0 commit comments