Commit ba6fc29
@turf/line-arc: always reach bearing2 (fix dropped final vertex) (#3078)
The arc was generated with `while (alpha <= arcEndDegree)`, advancing
`alpha = arcStartDegree + i * arcStep`. For some bearing/step
combinations this accumulated angle overshoots `arcEndDegree` by a
floating-point epsilon on the final iteration (e.g. `0 + 7 * (29 / 7)`
=== `29.000000000000004`), so the loop exits one step early.
The result was an arc with `steps` vertices instead of the documented
`steps + 1`, ending a full `arcStep` short of `bearing2`
(e.g. `lineArc(center, 5, 0, 29, { steps: 7 })` stopped at ~24.857°
instead of 29°).
Iterate a fixed `steps + 1` times and pin the last vertex to
`arcEndDegree` so the arc always ends exactly on `bearing2`. Behaviour is
unchanged for inputs that did not trigger the rounding overshoot.
Co-authored-by: mfedderly <24275386+mfedderly@users.noreply.github.com>1 parent 0e86d5b commit ba6fc29
3 files changed
Lines changed: 37 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | 60 | | |
62 | | - | |
63 | 61 | | |
64 | 62 | | |
65 | | - | |
66 | | - | |
67 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
68 | 72 | | |
69 | 73 | | |
70 | 74 | | |
71 | | - | |
72 | | - | |
73 | 75 | | |
74 | 76 | | |
75 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
0 commit comments