ported rivet to typst

This commit is contained in:
2024-05-19 12:11:41 +02:00
parent f163a0548d
commit 5e0972037f
8 changed files with 766 additions and 0 deletions

44
src/vec.typ Normal file
View File

@ -0,0 +1,44 @@
#let vec(x, y) = {
return (x: x, y: y)
}
#let add(v1, v2) = {
return vec(
v1.x + v2.x,
v1.y + v2.y
)
}
#let sub(v1, v2) = {
return vec(
v1.x - v2.x,
v1.y - v2.y
)
}
#let mul(v, f) = {
return vec(
v.x * f,
v.y * f
)
}
#let div(v, f) = {
return vec(
v.x / f,
v.y / f
)
}
#let mag(v) = {
return calc.sqrt(v.x * v.x + v.y * v.y)
}
#let normalize(v) = {
let m = mag(v)
if m == 0 {
return (x: 0, y: 0)
}
return div(v, m)
}