From 01d8d134373d1d3431c32d08a98fe10630dc29f5 Mon Sep 17 00:00:00 2001 From: Yerlotic <108224581+yerlotic@users.noreply.github.com> Date: Wed, 8 Jul 2026 22:22:47 +0000 Subject: [PATCH 1/4] Improve karls-picture.typ - Fix spelling mistakes in comments - Make angle into a variable - Fix rendering for angles > 90 degrees --- gallery/karls-picture.typ | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/gallery/karls-picture.typ b/gallery/karls-picture.typ index b86771bb..1bcf4510 100644 --- a/gallery/karls-picture.typ +++ b/gallery/karls-picture.typ @@ -7,6 +7,9 @@ #cetz.canvas(length: 3cm, { import cetz.draw: * + // Control the angle + let angle = 30deg + // Change the design for all elements after it set-style( // Design of arrow tips at the end of lines @@ -48,29 +51,35 @@ content((), anchor: "east", ct) } + // Position on the unit circle + let pos = (calc.cos(angle), calc.sin(angle)) + // Draw the green angle - cetz.angle.angle((0,0), (1,0), (1, calc.tan(30deg)), - label: text(green, [#sym.alpha])) + cetz.angle.angle((0,0), (1,0), pos, + label: text(green, $alpha$)) + + // Draw the hypotenuse of the triangle + line(pos, (1, calc.tan(angle))) + line(pos, (0, 0)) - // Draw the hypothenuse of the triangle - line((0,0), (1, calc.tan(30deg))) // Change the stroke for all upcoming elements set-style(stroke: (thickness: 1.2pt)) // Draw the inner opposite leg of the triangle: // "The intersection of a vertical line (|-) through (30deg, 1) and a horizontal line through (0, 0)" - line((30deg, 1), ((), "|-", (0,0)), stroke: (paint: red), name: "sin") + line((angle, 1), ((), "|-", (0,0)), stroke: (paint: red), name: "sin") // Place the text halfway through on the opposite leg content(("sin.start", 50%, "sin.end"), text(red)[$ sin alpha $]) - + // Draw the adjacent leg of the triangle line("sin.end", (0,0), stroke: (paint: blue), name: "cos") // Place the text halfway and position it below the line content(("cos.start", 50%, "cos.end"), text(blue)[$ cos alpha $], anchor: "north") // Draw the outer opposite leg of the triangle - line((1, 0), (1, calc.tan(30deg)), name: "tan", stroke: (paint: orange)) - // Draw the tangent equasion at the top and to the right of the line + line((1, 0), (1, calc.tan(angle)), name: "tan", stroke: (paint: orange)) + + // Draw the tangent equation at the top and to the right of the line content("tan.end", $ text(#orange, tan alpha) = text(#red, sin alpha) / text(#blue, cos alpha) $, anchor: "west") }) From 9bdf2bb65b9365d127a47ff64983ba1dfc3756cf Mon Sep 17 00:00:00 2001 From: Yerlotic <108224581+yerlotic@users.noreply.github.com> Date: Sun, 12 Jul 2026 17:09:15 +0000 Subject: [PATCH 2/4] Use polar coordinates Co-authored-by: Johannes Wolf --- gallery/karls-picture.typ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gallery/karls-picture.typ b/gallery/karls-picture.typ index 1bcf4510..e72337fd 100644 --- a/gallery/karls-picture.typ +++ b/gallery/karls-picture.typ @@ -52,7 +52,7 @@ } // Position on the unit circle - let pos = (calc.cos(angle), calc.sin(angle)) + let pos = (angle, 1) // Draw the green angle cetz.angle.angle((0,0), (1,0), pos, From 5aa9eede914733dea4bf4954ea10199cd50809e7 Mon Sep 17 00:00:00 2001 From: Yerlotic <108224581+yerlotic@users.noreply.github.com> Date: Sun, 12 Jul 2026 17:10:26 +0000 Subject: [PATCH 3/4] Update gallery/karls-picture.typ Co-authored-by: Johannes Wolf --- gallery/karls-picture.typ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gallery/karls-picture.typ b/gallery/karls-picture.typ index e72337fd..0b42cf97 100644 --- a/gallery/karls-picture.typ +++ b/gallery/karls-picture.typ @@ -78,7 +78,7 @@ content(("cos.start", 50%, "cos.end"), text(blue)[$ cos alpha $], anchor: "north") // Draw the outer opposite leg of the triangle - line((1, 0), (1, calc.tan(angle)), name: "tan", stroke: (paint: orange)) + line((1, 0), (1, calc.tan(angle)), name: "tan", stroke: orange) // Draw the tangent equation at the top and to the right of the line content("tan.end", $ text(#orange, tan alpha) = text(#red, sin alpha) / text(#blue, cos alpha) $, anchor: "west") From bd31aafd9bafa3f6117d3fb7c5405759d64aa307 Mon Sep 17 00:00:00 2001 From: Yerlotic <108224581+yerlotic@users.noreply.github.com> Date: Sun, 12 Jul 2026 17:31:20 +0000 Subject: [PATCH 4/4] Improve even more --- gallery/karls-picture.typ | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/gallery/karls-picture.typ b/gallery/karls-picture.typ index 0b42cf97..b229c5a7 100644 --- a/gallery/karls-picture.typ +++ b/gallery/karls-picture.typ @@ -1,14 +1,14 @@ #import "@preview/cetz:0.5.2" #set page(width: auto, height: auto, margin: .5cm) -#show math.equation: block.with(fill: white, inset: 1pt) +#show math.equation: block.with(fill: white, inset: 1pt, radius: 2pt) // Create a new canvas to draw on #cetz.canvas(length: 3cm, { import cetz.draw: * // Control the angle - let angle = 30deg + let angle = 212deg // Change the design for all elements after it set-style( @@ -21,14 +21,15 @@ radius: 0.3, label-radius: .22, fill: green.lighten(80%), - stroke: (paint: green.darken(50%)) + stroke: green.darken(50%) ), // Design of all text elements with an anchor content: (padding: 1pt) ) - // Draws the grid behind the circle - grid((-1.5, -1.5), (1.4, 1.4), step: 0.5, stroke: gray + 0.2pt) + // Draw the grids behind the circle + grid((-1.5, -1.5), (1.5, 1.5), step: 0.25, stroke: gray + 0.1pt) + grid((-1.5, -1.5), (1.5, 1.5), step: 0.5, stroke: gray + 0.2pt) // Draw the unit circle circle((0,0), radius: 1) @@ -51,12 +52,12 @@ content((), anchor: "east", ct) } - // Position on the unit circle + // Position on the unit circle (in polar coordinates) let pos = (angle, 1) // Draw the green angle cetz.angle.angle((0,0), (1,0), pos, - label: text(green, $alpha$)) + label: text(green, $alpha = angle.deg() degree$)) // Draw the hypotenuse of the triangle line(pos, (1, calc.tan(angle))) @@ -68,12 +69,12 @@ // Draw the inner opposite leg of the triangle: // "The intersection of a vertical line (|-) through (30deg, 1) and a horizontal line through (0, 0)" - line((angle, 1), ((), "|-", (0,0)), stroke: (paint: red), name: "sin") + line(pos, ((), "|-", (0,0)), stroke: red, name: "sin") // Place the text halfway through on the opposite leg content(("sin.start", 50%, "sin.end"), text(red)[$ sin alpha $]) // Draw the adjacent leg of the triangle - line("sin.end", (0,0), stroke: (paint: blue), name: "cos") + line("sin.end", (0,0), stroke: blue, name: "cos") // Place the text halfway and position it below the line content(("cos.start", 50%, "cos.end"), text(blue)[$ cos alpha $], anchor: "north")