diff --git a/PyPost.py b/PyPost.py index 77ee0f9..6de996d 100644 --- a/PyPost.py +++ b/PyPost.py @@ -15,7 +15,7 @@ from watchdog.observers import Observer from log.Logger import * from hashes.hashes import hash_list -from htmlhandler import htmlhandler as Handler +from htmlhandler import htmlhandler from lua import plugin_manager # Import your LaTeX extension @@ -259,7 +259,7 @@ if __name__ == "__main__": Logger.log_warning("Using Python parser for all files") initial_scan(MARKDOWN_DIR) - event_handler = Handler() + event_handler = htmlhandler(render_markdown, remove_html) observer = Observer() observer.schedule(event_handler, str(MARKDOWN_DIR), recursive=True) observer.start() diff --git a/html/Rotation.html b/html/Rotation.html new file mode 100644 index 0000000..f1680d7 --- /dev/null +++ b/html/Rotation.html @@ -0,0 +1,245 @@ + + + + + + Rotation eines Würfels mit Matrizen + + + + + + + + + + + + + + + + + + + + + + + +
+

+ ⬅ + Rotation eines Würfels mit Matrizen +

+ 📄 +
+ Written @Wed May 27 11:21:22 2026 +
+
+
+

Rotation eines Würfels mit Matrizen

+

1. Der Würfel im Raum

+

Ein Würfel im Ursprung des Koordinatensystems (Mittelpunkt bei ( (0,0,0) )) und der Kantenlänge 2 besitzt die Eckpunkte:

+ +
$$ +\begin{aligned} +A &= (1, 1, 1), & B &= (1, 1, -1), & C &= (1, -1, 1), \\ +D &= (1, -1, -1), & E &= (-1, 1, 1), & F &= (-1, 1, -1), \\ +G &= (-1, -1, 1), & H &= (-1, -1, -1) +\end{aligned} +$$
+

Jeder Punkt kann als Spaltenvektor dargestellt werden:

+ +
$$ +\mathbf{v} = +\begin{pmatrix} +x \\ +y \\ +z +\end{pmatrix}. +$$
+

Eine Drehung des Würfels im Raum kann mathematisch durch Multiplikation mit einer Rotationsmatrix beschrieben werden.

+
+

2. Rotationsmatrizen im 3D-Raum

+

Eine Rotationsmatrix beschreibt eine Drehung um eine bestimmte Achse. Dabei bleibt die Länge der Vektoren unverändert, ebenso die Winkel zwischen ihnen. +Es gibt drei elementare Rotationen: um die x-Achse, die y-Achse und die z-Achse.

+
+

a) Rotation um die x-Achse

+ +
$$ +\mathbf{v}' = R_x(\theta)\mathbf{v} = +\begin{pmatrix} +x \\ +y \cos\theta - z \sin\theta \\ +y \sin\theta + z \cos\theta +\end{pmatrix} +$$
+

Die x-Koordinate bleibt bei dieser Drehung unverändert. Der Punkt

+ +
$$ +\mathbf{v}' = R_x(\theta)\mathbf{v} = +\begin{pmatrix} +x \\ +y \cos\theta - z \sin\theta \\ +y \sin\theta + z \cos\theta +\end{pmatrix} +$$
+
+

b) Rotation um die y-Achse

+ +
$$ +R_y(\theta) = +\begin{pmatrix} +\cos\theta & 0 & \sin\theta \\ +0 & 1 & 0 \\ +-\sin\theta & 0 & \cos\theta +\end{pmatrix} +$$
+

Dabei bleibt die y-Koordinate gleich, x und z verändern sich.

+ +
$$ +\mathbf{v}' = R_y(\theta)\mathbf{v} = +\begin{pmatrix} +x \cos\theta + z \sin\theta \\ +y \\ +- x \sin\theta + z \cos\theta +\end{pmatrix} +$$
+
+

c) Rotation um die z-Achse

+ +
$$ +R_z(\theta) = +\begin{pmatrix} +\cos\theta & -\sin\theta & 0 \\ +\sin\theta & \cos\theta & 0 \\ +0 & 0 & 1 +\end{pmatrix} +$$
+

Hier bleibt z unverändert, während x und y rotieren.

+ +
$$ +\mathbf{v}' = R_z(\theta)\mathbf{v} = +\begin{pmatrix} +x \cos\theta - y \sin\theta \\ +x \sin\theta + y \cos\theta \\ +z +\end{pmatrix} +$$
+
+

3. Kombination mehrerer Rotationen

+

Oft wird ein Objekt nacheinander um mehrere Achsen gedreht. +Die Gesamtrotation ergibt sich durch Multiplikation der einzelnen Rotationsmatrizen.

+

Beispiel:

+ +
$$ +R_{\text{gesamt}} = R_x(\alpha) \cdot R_y(\beta) \cdot R_z(\gamma). +$$
+

Ein Punkt \(v\) wird dann abgebildet auf:

+ +
$$ +\mathbf{v}' = R_{\text{gesamt}}\mathbf{v}. +$$
+

Die Reihenfolge ist dabei wesentlich, da die Matrixmultiplikation nicht kommutativ ist:

+ +
$$ +R_x R_y \neq R_y R_x. +$$
+

Das bedeutet: Zuerst um die x-Achse und danach um die y-Achse zu drehen führt zu einem anderen Ergebnis, als die Reihenfolge umzukehren.

+
+

4. Matrixmultiplikation

+

Die Multiplikation zweier Matrizen (A) und (B) (jeweils 3×3) ergibt eine neue Matrix (C = A \cdot B) mit den Einträgen:

+ +
$$ +c_{ij} = a_{i1}b_{1j} + a_{i2}b_{2j} + a_{i3}b_{3j}. +$$
+

Allgemein gilt:

+ +

So kann man Schritt für Schritt die Gesamtrotationsmatrix berechnen.

+
+

5. Beispiel für (\(\theta = 45^\circ\))

+

Für den Winkel \(\theta = 45^\circ = \frac{\pi}{4}\) gilt:

+ +
$$ +\cos\theta = \sin\theta = \frac{\sqrt{2}}{2}. +$$
+

Damit lautet die Rotationsmatrix um die x-Achse:

+ +
$$ +R_x(45^\circ) = +\begin{pmatrix} +1 & 0 & 0 \\ +0 & \tfrac{\sqrt{2}}{2} & -\tfrac{\sqrt{2}}{2} \\ +0 & \tfrac{\sqrt{2}}{2} & \tfrac{\sqrt{2}}{2} +\end{pmatrix} +$$
+

Wendet man diese Matrix auf den Punkt \(\mathbf{A} = (1, 1, 1)\) an, ergibt sich:

+ +
$$ +\begin{aligned} +x' &= 1, \\ +y' &= 1 \cdot \tfrac{\sqrt{2}}{2} - 1 \cdot \tfrac{\sqrt{2}}{2} = 0, \\ +z' &= 1 \cdot \tfrac{\sqrt{2}}{2} + 1 \cdot \tfrac{\sqrt{2}}{2} = \sqrt{2}. +\end{aligned} +$$
+

Der neue Punkt ist also:

+ +
$$ +\mathbf{A}' = (1, 0, \sqrt{2}). +$$
+

Der Punkt wurde damit um die x-Achse um 45° gedreht.

+
+

6. Zusammenfassung

+ + +
+
+ + + + diff --git a/htmlhandler.py b/htmlhandler.py index c0e8a0c..77acfcb 100644 --- a/htmlhandler.py +++ b/htmlhandler.py @@ -1,29 +1,27 @@ from pathlib import Path from watchdog.events import FileSystemEventHandler -# this has to be like this. idk why. its ass - class htmlhandler(FileSystemEventHandler): + def __init__(self, render_func, remove_func): + self.render_func = render_func + self.remove_func = remove_func + def on_created(self, event): if not event.is_directory and event.src_path.endswith(".md"): - import PyPost - PyPost.render_markdown(Path(event.src_path)) + self.render_func(Path(event.src_path)) def on_modified(self, event): if not event.is_directory and event.src_path.endswith(".md"): - import PyPost - PyPost.render_markdown(Path(event.src_path)) + self.render_func(Path(event.src_path)) def on_deleted(self, event): if not event.is_directory and event.src_path.endswith(".md"): - import PyPost - PyPost.remove_html(Path(event.src_path)) + self.remove_func(Path(event.src_path)) def on_moved(self, event): src = Path(event.src_path) dest = Path(event.dest_path) - import PyPost if src.suffix.lower() == ".md": - PyPost.remove_html(src) + self.remove_func(src) if dest.suffix.lower() == ".md": - PyPost.render_markdown(dest) \ No newline at end of file + self.render_func(dest) \ No newline at end of file diff --git a/lua/plugins/examples/md_banner.lua b/lua/plugins/examples/md_banner.lua new file mode 100644 index 0000000..369ab64 --- /dev/null +++ b/lua/plugins/examples/md_banner.lua @@ -0,0 +1,9 @@ +register_hook("pre_template", function(md_path, html_body) + -- Check if the current markdown path is for test.md + if md_path and md_path:match("test%.md$") then + local banner = "
Note: served via Lua plugin banner
" + return banner .. html_body + end + -- For other pages, return the original HTML body unchanged + return html_body +end) \ No newline at end of file diff --git a/tmp_requirements.txt b/tmp_requirements.txt new file mode 100644 index 0000000..6c7d2e7 --- /dev/null +++ b/tmp_requirements.txt @@ -0,0 +1,14 @@ +certifi==2026.5.20 +charset-normalizer==3.4.7 +colorama==0.4.6 +idna==3.16 +Jinja2==3.1.6 +jsmin==3.0.1 +lupa==2.5 +marko==2.2.0 +MarkupSafe==3.0.3 +pillow==11.3.0 +PyYAML==6.0.3 +requests==2.32.5 +urllib3==2.7.0 +watchdog==6.0.0 diff --git a/webserver.py b/webserver.py index ef6151f..35e8cc5 100644 --- a/webserver.py +++ b/webserver.py @@ -279,7 +279,7 @@ def get_html_files(directory=HTML_DIR): return html_files _index_cache = {"content": None, "timestamp": 0} -INDEX_CACHE_TTL = 300 # 300/60 = 5min +INDEX_CACHE_TTL = 10 # 300/60 = 5min def build_index_page(force_refresh: bool = False) -> str: """Build index page with caching""" @@ -460,7 +460,7 @@ class WebServerHTTPRequestHandler(BaseHTTPRequestHandler): # Handle root/index with caching if req_path == "" or req_path == "index.html": - content = build_index_page() + content = build_index_page(True) self._send_compressed_response( content.encode("utf-8"), "text/html",