Files
maing01_06/Band5/grafiken.typ
T
2026-04-06 11:38:08 +02:00

317 lines
6.5 KiB
Typst

#import "@preview/fletcher:0.5.8" as fletcher: diagram, node, edge
#import "@preview/cetz:0.4.2" //Grafiken
#import "@preview/cetz-plot:0.1.3": plot
#let bent-edge(from, to, ..args) = {
let midpoint = (from, 50%, to)
let vertices = (
from,
(from, "|-", midpoint),
(midpoint, "-|", to),
to,
)
edge(..vertices, "-|", ..args)
}
#let b3_0 = diagram(
node-stroke: luma(80%),
edge-corner-radius: none,
spacing: (10pt, 20pt),
// Nodes
node((1.5,0), [1.#h(3mm)2.#h(3mm)3.1.], name: <a>),
node((0.5,1), [4.1.-4.3.], name: <b>),
node((2.5,1), [3.2.-3.3.], name: <c>),
node((0,2), [4.4.-4.5.], name: <d>),
node((1,2), [4.6.], name: <e>),
node((2.501,2), [5.1.-5.5.], name: <f>),
node((2,3), [5.6.], name: <g>),
node((3,3), [5.7.], name: <h>),
node((4,3), [5.8.], name: <i>),
node((5,3), [5.9.], name: <j>),
node((6,3), [5.10.], name: <k>),
node((2.001,4), [#h(1mm)6.#h(1mm) ], name: <m>),
// Edges
bent-edge(<a>, <b>),
bent-edge(<a>, <c>),
bent-edge(<b>, <d>),
bent-edge(<b>, <e>),
bent-edge(<c>, <f>),
bent-edge(<c>, <f>),
bent-edge(<f>, <g>),
bent-edge(<f>, <h>),
bent-edge(<f>, <i>),
bent-edge(<f>, <j>),
bent-edge(<f>, <k>),
bent-edge(<g>, <m>),
)
#let sq45 = rotate(45deg)[
#square(size: 4pt, stroke: gray)
]
#let pat1 = tiling(size: (5pt, 5pt))[
#place(line(start: (0%, 100%), end: (100%, 0%),stroke: gray, ))
]
// 1. Wir definieren das Muster außerhalb der Canvas
#let mein-kachel-muster = tiling(size: (20pt, 20pt))[
// Wir nutzen place, um das Quadrat exakt in der Kachel-Mitte zu drehen
#place(center, rotate(45deg)[
#square(size: 10pt, fill: blue.lighten(50%), stroke: 0.5pt)
])
]
#let b2_4 = cetz.canvas({
import cetz.draw: *
//import cetz-plot: *
let f = x => (0.01 * calc.pow(x, 3) - 0.2 * calc.pow(x, 2) + 0.8 * x + 3) + 5
let g = x => -(0.01 * calc.pow(x, 3) - 0.2 * calc.pow(x, 2) + 0.8 * x + 3) + 5
plot.plot(
size: (6, 7),
name: "plot",
axis-style: "school-book",
x-tick-step: none,
y-tick-step: none,
x-label: $x$,
y-label: $y$,
x-ticks: ((3, $x_1$), (12, $x_2$), (8, $x$)),
{
plot.add(domain: (2, 13), f, style: (stroke: red), samples: 300)
plot.add(domain: (2, 13), g, style: (stroke: blue), samples: 300)
plot.add-fill-between(
domain: (3, 12),
g,
f,
style: (
stroke: none,
//fill: tiling(size: (5pt, 5pt), square(stroke: gray, radius: 3mm)),
//fill: tiling(size: (5pt, 5pt), sq45),
fill: pat1,
),)
// Hilfslinie damit Koordinatensystem nicht verrutscht
plot.add(((0, 0), (0, 0.1)), style: (stroke: none))
plot.add-anchor("G1", (3, g(3)))
plot.add-anchor("F1", (3, f(3)))
plot.add-anchor("G1", (12, g(12)))
plot.add-anchor("G1", (12, g(12)))
plot.add(((3, 0), (3, f(3))), style: (stroke: (dash: "dashed", paint: gray, thickness: 1pt)))
plot.add(((12, 0), (12, f(12))), style: (stroke: (dash: "dashed", paint: gray, thickness: 1pt)))
},
)
})
#let EC_func(x) = {
let y = x*x*x - 4*x + 6
if y < 0 {
return 0
}
return calc.sqrt(y)
}
#let EC_drawing = cetz.canvas({
plot.plot(
size: (10, 10),
x-tick-step: 5,
y-tick-step: 20,
x-min: -5,
max: 10,
x-grid: true,
y-grid: true,
{
plot.add(domain: (-5, 10), EC_func, samples: 300)
plot.add(domain: (-5, 10), t => (t, -EC_func(t)),samples: 300)
})
})
#let EC_func2(x) = {
let y = (x - 3)*(x - 3)*(x - 3) - 4*(x - 3) + 12
if y < 0 {
return 0
}
return calc.sqrt(y)
}
#let EC_func3(x) = {
let y = -((x - 3)*(x - 3)*(x - 3) - 4*(x - 3)) + 4
if y < 0 {
return 0
}
return calc.sqrt(y)
}
#let EC_drawing2 = cetz.canvas({
plot.plot(
name: "plot",
axis-style: "school-book",
size: (10, 10),
x-tick-step: none,
y-tick-step: 20,
x-min: 0,
x-max: 7,
x-grid: true,
y-grid: true,
{
plot.add(((0, 0), (0, 0.1)), style: (stroke: none))
plot.add(domain: (1, 6), EC_func2, samples: 300)
plot.add(domain: (1, 6), EC_func3,samples: 300)
})
})
#let size = (6, 4)
#let f(x, y: 0) = y + calc.sin(x * 1deg)
/* Fill between */
#let test-case = cetz.canvas({
plot.plot(size: size,
x-tick-step: none,
y-tick-step: none,
{
plot.add-fill-between(domain: (-360, 360), f.with(y: -1), f.with(y: 1))
})
})
#let test-case2 = cetz.canvas({
plot.plot(size: size,
x-tick-step: none,
y-tick-step: none,
y-max: .5,
{
plot.add-fill-between(domain: (-360, 360), f.with(y: -1), f.with(y: 1))
})
})
#let test-case3 = cetz.canvas({
plot.plot(size: size,
x-tick-step: none,
y-tick-step: none,
y-min: -.5,
{
plot.add-fill-between(domain: (-360, 360), f.with(y: -1), f.with(y: 1))
})
})
#let test-case4 = cetz.canvas({
plot.plot(size: size,
x-tick-step: none,
y-tick-step: none,
y-max: .5,
y-min: -.5,
{
plot.add-fill-between(domain: (-360, 360), f.with(y: -1), f.with(y: 1))
})
})
#let test-case5 = cetz.canvas({
plot.plot(size: size,
x-tick-step: none,
y-tick-step: none,
{
plot.add-fill-between(domain: (0, 2 * calc.pi),
t => (calc.cos(t) * 1.5, calc.sin(t)),
t => (calc.cos(t), calc.sin(t) * 1.5))
})
})
#let test-case6 = cetz.canvas({
plot.plot(size: size,
x-tick-step: none,
y-tick-step: none,
{
plot.add-fill-between(domain: (0, 2 * calc.pi),
t => (calc.cos(t) * 1.5, calc.sin(t) * 1.5),
t => (calc.cos(t), calc.sin(t)))
})
})
#let test-case7 = cetz.canvas({
let f(x) = calc.sin(x) + calc.cos(3 * x)
plot.plot(size: size,
x-tick-step: none,
y-tick-step: none,
{
// Function
plot.add(domain: (0, 4 * calc.pi), f)
// Error-Band fill
plot.add-fill-between(domain: (0, 4 * calc.pi),
style: (stroke: none),
x => f(x) - calc.exp(x/4) / 2,
x => f(x) + calc.exp(x/4) / 2)
})
})
#let pat1 = tiling(size: (20pt, 20pt))[
#place(line(start: (0%, 100%), end: (100%, 0%)))
]
#import "@preview/modpattern:0.1.0": modpattern
#let pat = modpattern((20pt, 20pt))[
#move(dx: 50%, line(start: (0%, 100%), end: (100%, 0%)))
]
#rect(fill: pat, width: 8cm, height: 5cm, stroke: 1pt)
#let test-case8 = cetz.canvas({
import cetz.palette
plot.plot(size: size,
x-tick-step: none,
y-tick-step: none,
{
plot.add-fill-between(domain: (0, 2 * calc.pi),
t => (calc.cos(t) * 1.5, calc.sin(t)),
t => (calc.cos(t), calc.sin(t) * 1.5), style: palette.pink)
})
})