-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
shapes: Add hobby curve implementation
- Loading branch information
1 parent
891aba1
commit 784e61f
Showing
13 changed files
with
513 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Real and imaginary part | ||
#let re(V) = V.at(0) | ||
#let im(V) = V.at(1) | ||
|
||
// Complex multiplication | ||
#let mul(V,W) = (re(V)*re(W) - im(V)*im(W),im(V)*re(W) + re(V)*im(W)) | ||
|
||
// Complex conjugate | ||
#let conj(V) = (re(V),-im(V)) | ||
|
||
// Dot product of V and W as vectors in R^2 | ||
#let dot(V,W) = re(mul(V,conj(W))) | ||
|
||
// Norm and norm-squared | ||
#let normsq(V) = dot(V,V) | ||
#let norm(V) = calc.sqrt(normsq(V)) | ||
|
||
// V*t | ||
#let scale(V,t) = mul(V,(t,0)) | ||
|
||
// Unit vector in the direction of V | ||
#let unit(V) = scale(V, 1/norm(V)) | ||
|
||
// V^(-1) as a complex number | ||
#let inv(V) = scale(conj(V), 1/normsq(V)) | ||
|
||
// V / W | ||
#let div(V,W) = mul(V,inv(W)) | ||
|
||
// V + W and V - W | ||
#let add(V,W) = (re(V) + re(W),im(V) + im(W)) | ||
#let sub(V,W) = (re(V) - re(W),im(V) - im(W)) | ||
|
||
// Argument | ||
#let arg(V) = calc.atan2(..V) / 1rad | ||
|
||
// Signed angle from V to W | ||
#let ang(V,W) = arg(div(W,V)) | ||
|
||
// exp(i*a) | ||
#let expi(a) = (calc.cos(a),calc.sin(a)) | ||
|
||
// Rotate by angle a | ||
#let rot(v,a) = mul(v,expi(a)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#import "draw/grouping.typ": intersections, group, anchor, copy-anchors, place-anchors, set-ctx, get-ctx, for-each-anchor, on-layer, place-marks | ||
#import "draw/transformations.typ": rotate, translate, scale, set-origin, move-to, set-viewport | ||
#import "draw/styling.typ": set-style, fill, stroke | ||
#import "draw/shapes.typ": circle, circle-through, arc, mark, line, grid, content, rect, bezier, bezier-through, catmull, merge-path, shadow | ||
#import "draw/shapes.typ": circle, circle-through, arc, mark, line, grid, content, rect, bezier, bezier-through, catmull, hobby, merge-path, shadow |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.