Logo web por rotación
PyGgb: Python and GeoGebra Integration
PyGgb is an online environment where you can program in Python and see the graphical results in GeoGebra by communicating through its API. Still in its beta version, this is an interesting idea because GeoGebra's built-in language is quite limited, making the generation of some animations very complex.
Unfortunately, there is no clear documentation, and understanding the commands can be challenging.
You can find more information here.
I wanted to start experimenting with this environment with something very simple: the logo created by rotation for this website.
Click here to see the code in the PyGgb environment: Link

Código
Text Only |
---|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 | import time
import math
P1 = Point(0, 0)
# Figure initiale
A = Point(0.25, 2.53)
B = Point(1.42, 2.13)
C = Point(1, 0.95)
D = Point(-0.44, 0.65)
# Les points sont mobiles dans le cadre Ggb et la figure totalement dynamique
E = Point(0.17, 2.56)
F = Point(-0.26, 1.4)
G = Point(-0.61, 1.97)
puntos_cuadrilatero = [A,B,C,D]
figure1 = Polygon(puntos_cuadrilatero, color = "black", opacity=1)
puntos_triangulo=[E,F,G]
figure2 = Polygon(puntos_triangulo, color = "black", opacity=1)
for punto in puntos_cuadrilatero:
punto.color="black"
punto.is_visible=False
for punto in puntos_triangulo:
punto.color="black"
punto.is_visible=False
def rotar_puntos(lista_puntos, angulo, origen):
lista_rotada = [] # Lista donde se guardarán los puntos rotados
for punto in lista_puntos:
# Calcula la rotación del punto en torno al origen
punto_rotado = Rotate(punto, angulo, origen)
# Añadir el punto rotado a la lista
punto_rotado.is_visible = False
lista_rotada.append(punto_rotado)
# Crear el polígono con los puntos rotados
return Polygon(lista_rotada, color="black", opacity=1)
for i in range(1,6):
rotar_puntos(puntos_cuadrilatero ,i*2*math.pi/6, P1)
rotar_puntos(puntos_triangulo ,i*2*math.pi/6, P1)
|