Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
kurse:efcomputergrafik:kw48 [2019/11/27 10:49] Ivo Blöchliger [Ableitungen von $p(t)$ für $t \in [0,1]$] |
kurse:efcomputergrafik:kw48 [2019/12/04 11:48] Ivo Blöchliger |
||
---|---|---|---|
Line 40: | Line 40: | ||
$$-6\, | $$-6\, | ||
| | ||
+ | |||
+ | Interessant sind auch hier die Werte von $a(0)$ und $a(1)$: | ||
+ | $$a(0) = 6\, | ||
+ | $$a(1) = 6\, | ||
Line 98: | Line 102: | ||
===== Umgang mit Inkscape ===== | ===== Umgang mit Inkscape ===== | ||
+ | |||
+ | Download für die Schulcomputer: | ||
+ | |||
Nützliche Tastenkombinationen: | Nützliche Tastenkombinationen: | ||
* F1: Auswahlmodus (zum kopieren, löschen, verschieben, | * F1: Auswahlmodus (zum kopieren, löschen, verschieben, | ||
- | * F2: Edit-Modus (Manipulation der Pfadelemente. | + | * F2: Edit-Modus (Manipulation der Pfadelemente). |
Pfad-Manipulationen: | Pfad-Manipulationen: | ||
Line 106: | Line 113: | ||
* Ctrl-K: Combine (mehrere Pfade in einen Pfad zusammenfassen). | * Ctrl-K: Combine (mehrere Pfade in einen Pfad zusammenfassen). | ||
- | ===== G-Code für den Plotter | + | ===== Text-Analyse mit Python |
- | Der Nullpunkt befindet sich bei den Radien $r_1=r_2=1445$ (in mm). Pro Motorschritt verändern sich die Radien | + | === Datei einlesen === |
+ | Von https:// | ||
+ | <code python> | ||
+ | with open(' | ||
+ | content = content_file.read() | ||
+ | </ | ||
+ | === Text finden === | ||
+ | https:// | ||
+ | <code python> | ||
+ | position = content.find("< | ||
+ | if (position!=-1): # Wirklich was gefunden | ||
+ | # tu was damit | ||
+ | </ | ||
+ | === Substring === | ||
+ | <code python> | ||
+ | a=" | ||
+ | a[2:5] # -> liefert " | ||
+ | </ | ||
+ | === Text Analyse === | ||
+ | Ist der Path-String einmal gefunden, geht es darum, diesen zu analysieren. Als erster Schritt soll dieser nach Leerschlägen aufgeteilt werden: | ||
+ | <code python> | ||
+ | txt = "foo bar baz boo" | ||
+ | items = txt.split(" | ||
+ | </ | ||
- | Der G-Code bezieht sich direkt auf die Motorenschritte | + | === Convertierung in Zahlen === |
+ | <code python> | ||
+ | zahl = float("3.14") | ||
+ | </ | ||
- | Nur G1 (lineare Interpolation) ist implementiert: | ||
- | * G1 X-400 Y800 (Gehe zur absoluten Position -400 Schritte (Motor links) und +800 Schritte (Motor rechts). | ||
- | * G1 Z0 (Stift hoch, nicht zeichnen) | ||
- | * G1 Z1 (Stift runter, zeichnen) | ||
- | Nach jedem Kommando muss auf ein ' | ||
+ | <hidden converter.py> | ||
+ | <code python converter.py> | ||
+ | |||
+ | def convert(elements): | ||
+ | # Aktuelle Koordinaten | ||
+ | x = 0 | ||
+ | y = 0 | ||
+ | # Position im elements Array | ||
+ | e = 0 | ||
+ | # letztes Kommando | ||
+ | lastCMD = "" | ||
+ | while e < len(elements): | ||
+ | if elements[e]==" | ||
+ | x = float(elements[e+1]) | ||
+ | y = float(elements[e+2]) | ||
+ | e = e+3 # 3 Element konsumiert | ||
+ | elif elements[e]==" | ||
+ | x = x + float(elements[e+1]) | ||
+ | y = y + float(elements[e+2]) | ||
+ | e = e+3 # 3 Element konsumiert | ||
+ | |||
+ | |||
+ | |||
+ | with open(' | ||
+ | content = content_file.read() | ||
+ | | ||
+ | # print(content) | ||
+ | # Anfangsposition vom path | ||
+ | position = content.find("< | ||
+ | if position< | ||
+ | raise BaseException(" | ||
+ | |||
+ | # | ||
+ | # Erste 20 Zeichen vom path | ||
+ | # | ||
+ | |||
+ | # d=" suchen... (ab der Position position) | ||
+ | while True: | ||
+ | position = content.find(" | ||
+ | if position< | ||
+ | BaseException(" | ||
+ | | ||
+ | if content[position-1]<' | ||
+ | break | ||
+ | | ||
+ | position+=1 | ||
+ | # Erste 20 Zeichen vom d | ||
+ | |||
+ | start = position+3 | ||
+ | ende = content.find(" | ||
+ | |||
+ | pfaddef = content[start: | ||
+ | print(pfaddef) | ||
+ | pfaddef = pfaddef.replace(",", | ||
+ | print(pfaddef) | ||
+ | elemente = pfaddef.split(" | ||
+ | print(elemente) | ||
+ | |||
+ | </ | ||
+ | </ | ||