Skip to content
This repository was archived by the owner on Mar 31, 2020. It is now read-only.

Commit 1ae61b3

Browse files
committed
Midpoint fix
1 parent 609d6a5 commit 1ae61b3

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/__main__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
from .animate import vector, Coord
44

5-
start = Coord(0, 0)
6-
end = Coord(120, 0)
5+
start = Coord(0, 5)
6+
end = Coord(5, 0)
77

8-
result = vector(start, end, 64)
8+
result = vector(start, end, 5)
99
print(len(result), result)

src/animate.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,14 @@ def vector(start: Coord, end: Coord, step: int = 60) -> List[Coord]:
154154
example::
155155
156156
```
157-
start = Coord(0, 0)
157+
start = Coord(0, 5)
158158
end = Coord(5, 0)
159-
vector(start, end, 5)
160-
>>> [Coord(x=0, y=0), Coord(x=1, y=0), Coord(x=2, y=0), Coord(x=4, y=0)]
159+
vector(start, end, 5) # ends up being 8
160+
>>> [
161+
Coord(x=0, y=5), Coord(x=1, y=4), Coord(x=1, y=4),
162+
Coord(x=2, y=2), Coord(x=2, y=2), Coord(x=4, y=1),
163+
Coord(x=4, y=1), Coord(x=5, y=0)
164+
]
161165
```
162166
163167
note:
@@ -172,4 +176,4 @@ def vector(start: Coord, end: Coord, step: int = 60) -> List[Coord]:
172176
front = vector(mid, end, step=instep)
173177
return back + front
174178
else:
175-
return [start]
179+
return [start, end]

0 commit comments

Comments
 (0)