Skip to content

Latest commit

 

History

History
196 lines (130 loc) · 6.72 KB

README.md

File metadata and controls

196 lines (130 loc) · 6.72 KB

space-filling-curves_python

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, ....)

2D Curves

sierspinski curve

hilbert_curve

Letters

P R S Z
Hilbert_A_2 Hilbert_B_2 Hilbert_C_2 Hilbert_H_2

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

Hilbert curve

hilbert_curve

Letters

A B C D
Hilbert_A_2 Hilbert_B_2 Hilbert_C_2 Hilbert_H_2

Gramatics

  • First Grammar

AHHB

  • Second Grammar

HAAC

  • Third Grammar

CBBH

  • fourth Grammar

BCCA

Peano curve

Peano_curve

Letters

P Q R S
Peano_P_2 Peano_Q_2 Peano_R_2 Peano_S_2

← → → ← ←

← ← ← → →

→ →→ ← ←

→ ←←→ →

Gramatics

  • First Grammar

PQPSRSPQP

  • Second Grammar

QPQRSRQPQ

  • Third Grammar

RSRQCQRSR

  • fourth Grammar

SRSPQPSRS

Gosper Flowsnake curve

Gosper_curve

Letters

G R
Peano_P_2 Peano_Q_2

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

Dragon curve

  • Being construct

Sorcha curve

(that a create to a friend)

Peano_P_2

A B C D
Peano_P_2 Peano_Q_2 Peano_R_2 Peano_S_2

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

3D Curves

Hilbert curve

hilbert_3d

A B C D
Peano_P_2 Peano_Q_2 Peano_R_2 Peano_S_2
E F G H
Peano_P_2 Peano_Q_2 Peano_R_2 Peano_S_2
I J K L
Peano_P_2 Peano_Q_2 Peano_R_2 Peano_S_2

Grammar

  • Being construct

Peano curve

peano_3d

P Q R S
Peano_P_2 Peano_Q_2 Peano_R_2 Peano_S_2