Skip to content

Commit

Permalink
Add vector distance function
Browse files Browse the repository at this point in the history
  • Loading branch information
fenjalien committed Apr 23, 2023
1 parent 1ccebf2 commit f506aad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 3 additions & 2 deletions circuitypst.typ
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#import "components.typ"
#import "utils.typ"

#import "../typst-canvas/draw.typ": *

#let node(component, position, name: none, anchor: none) ={
#let node(component, position, name: none, anchor: none) = {
group(name: name, anchor: anchor, {
assert(component in components.node, message: "Component '" + component + "' is unknown")
import "../typst-canvas/draw.typ": anchor
Expand Down Expand Up @@ -41,7 +42,7 @@
line(
(
(v1, v2) => {
let d = vector.dist(v1, v2)
let d = utils.dist(v1, v2)
vector.lerp(v1, v2, (d - 1.4) / (2 * d))
},
"outer.start",
Expand Down
12 changes: 12 additions & 0 deletions utils.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#import "../typst-canvas/vector.typ"

#let dist(v1, v2) = {
return calc.abs(
vector.len(
vector.sub(
v2,
v1
)
)
)
}

0 comments on commit f506aad

Please sign in to comment.