To product a video about Space-filling curve, i did a code based on Lindenmayer system, with objective animate with python
It can be used to teach about recursive functions, to product video and teach childrens about the turtle power.
To construct the curve faster, use https://github.com/PrincetonLIPS/numpy-hilbert-curve
Corrigir:
-
The 3d curves have a error at constants. At both
-
The Gosper_Flowsnake_curve have a little erro that make the iteraction >3 colapse in some lines Plus
- Add proprietis to change colors with make the iteractions
How to use
- Install the package
pip install L-SpaceCurves
from L_SpaceCurves import L_SpaceCurves_animation as ls
l = ls.L_SpaceCurves(leng=10, speed=0, iter=2, origin=(0, 0))
# leng is the size of each line to construct the curve
# speed is the speed to contruct the curve. 0 fast, 10 sloow
# iter is the total of iteractions that you wish (more iteractions is more time)
$ origin is a tuple that set the origin of curve ( nor always the center od curve is the center od figure)
from L_SpaceCurves import L_SpaceCurves as ls
l = ls.L_SpaceCurves(leng=10, speed=0, iter=2, origin=(0, 0))
# leng is the size of each line to construct the curve
# speed is the speed to contruct the curve. 0 fast, 10 sloow
# iter is the total of iteractions that you wish (more iteractions is more time)
$ origin is a tuple that set the origin of curve ( nor always the center od curve is the center od figure)
-
to plot in 2D, only select the start letter. Choose one below
-
to plot in 3D, select the start letter and call the function "plot()"
All the operations have reference of vector (1, 0, 0, ....)
Letters
P | R | S | Z |
---|---|---|---|
Gramatics
- First Grammar
S R P S
- Second Grammar
R Z S R
- Third Grammar
P S Z P
- fourth Grammar
Z P R Z
Letters
A | B | C | D |
---|---|---|---|
Gramatics
- First Grammar
A ↑ H → H ↓ B
- Second Grammar
H → A ↑ A ← C
- Third Grammar
C ← B ↓ B → H
- fourth Grammar
B ↓ C ← C ↑ A
Letters
P | Q | R | S |
---|---|---|---|
← → → ← ← |
← ← ← → → |
→ →→ ← ← |
→ ←←→ → |
Gramatics
- First Grammar
P ↑ Q ↑ P → S ↓ R ↓ S ↓ P ↑ Q ↑ P
- Second Grammar
Q ↑ P ↑ Q ← R ↓ S ↓ R ← Q ↑ P ↑ Q
- Third Grammar
R ↓ S ↓ R ← Q ↑ C ↑ Q ← R ↓ S ↓ R
- fourth Grammar
S ↓ R ↓ S ↓ P ↑ Q ↑ P ↓ S ↓ R ↓ S
Letters
G | R |
---|---|
Gramatics (arrow show the direction, but tha intensity is 60°)
- First Grammar
G ← ↑ R ← ↑ R ↑ → G ↑ → G ← ↑ G ↑ → R
- Second Grammar
G ← ↑ R ↑ → R ← ↑ R ← ↑ G ↑ → G ↑ → R
- Being construct
(that a create to a friend)
A | B | C | D |
---|---|---|---|
Gramatics (arrow show the direction, but tha intensity is 60°)
- First Grammar
B A C D A C A B C A B A C D A
- Second Grammar
D B A C B A B D C B B D C A B
- Third Grammar
D C A B C A C D B C D C A B C
- Four Grammar
C D B A D B D C A D C D B A D
A | B | C | D |
---|---|---|---|
E | F | G | H |
---|---|---|---|
I | J | K | L |
---|---|---|---|
Grammar
- Being construct
P | Q | R | S |
---|---|---|---|