Skip to content

Commit

Permalink
Fix vector.angle2 argument order
Browse files Browse the repository at this point in the history
  • Loading branch information
matthew-e-brown committed Nov 22, 2023
1 parent 37371a9 commit fb54cf2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/lib/angle.typ
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@
message: "Angle z coordinates of all three points must be equal")

let (s, e, ss) = {
let s = vector.angle2(origin, a) * -1
let s = vector.angle2(origin, a)
if s < 0deg { s += 360deg }
let e = vector.angle2(origin, b) * -1
let e = vector.angle2(origin, b)
if e < 0deg { e += 360deg }

if s > e {
Expand Down
3 changes: 2 additions & 1 deletion src/vector.typ
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@

/// Calculate angle between two points and the x-axis in 2d space
#let angle2(a, b) = {
return calc.atan2(a.at(1) - b.at(1), a.at(0) - b.at(0)) + 90deg
// Typst's atan2 is (x, y) order, not (y, x)
return calc.atan2(b.at(0) - a.at(0), b.at(1) - a.at(1))
}

/// Calculate angle between three points
Expand Down

0 comments on commit fb54cf2

Please sign in to comment.