import turtle
import random
# Configuration de la fenêtre
turtle.bgcolor("black")
t = turtle.Turtle()
t.speed(0)
t.width(2)
# Palette de couleurs vives
colors = ["#ff6b6b", "#feca57", "#48dbfb", "#1dd1a1", "#5f27cd", "#c8d6e5"]
# Fonction pour dessiner un motif
def motif(taille, angle, repetitions):
for i in range(repetitions):
t.color(random.choice(colors))
t.circle(taille)
t.right(angle)
taille += 3 # croissance progressive
# Positionnement initial
t.penup()
t.goto(0, 0)
t.pendown()
# Dessin du motif
motif(taille=30, angle=15, repetitions=60)
turtle.done()
import turtle
import random
t = turtle.Turtle()
t.speed(2)
turtle.bgcolor("black")
colors = ["#ff9ff3", "#feca57", "#1dd1a1", "#54a0ff", "#5f27cd"]
for i in range(120):
t.color(random.choice(colors))
t.forward(i * 3)
t.right(150)
import turtle
import random
t = turtle.Turtle()
t.speed(0)
turtle.bgcolor("black")
colors = ["#ff6b6b", "#48dbfb", "#1dd1a1", "#feca57"]
for i in range(36):
t.color(random.choice(colors))
t.circle(100)
t.right(10)
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# ---------------------------------------------------------
# Fonctions mathématiques 3D
# ---------------------------------------------------------
def f_sin_wave(x, y):
return np.sin(np.sqrt(x**2 + y**2))
def f_paraboloid(x, y):
return x**2 + y**2
def f_ripple(x, y):
return np.sin(x) * np.cos(y)
def f_super_gaussian(x, y):
r2 = x**2 + y**2
return np.exp(-(r2**2) / 2000)
# ---------------------------------------------------------
# Fonction générique de tracé
# ---------------------------------------------------------
def plot_3d(func, title="Surface 3D", cmap="viridis"):
fig = plt.figure(figsize=(10, 7))
ax = fig.add_subplot(111, projection="3d")
# Domaine
x = np.linspace(-10, 10, 300)
y = np.linspace(-10, 10, 300)
X, Y = np.meshgrid(x, y)
# Calcul de Z
Z = func(X, Y)
# Tracé
surf = ax.plot_surface(X, Y, Z, cmap=cmap, linewidth=0, antialiased=True)
ax.set_title(title)
ax.set_xlabel("X")
ax.set_ylabel("Y")
ax.set_zlabel("Z")
fig.colorbar(surf, shrink=0.5, aspect=10)
plt.show()
# ---------------------------------------------------------
# Exemples d'utilisation
# ---------------------------------------------------------
plot_3d(f_sin_wave, "Onde sinusoïdale 3D", cmap="plasma")
# plot_3d(f_paraboloid, "Paraboloïde", cmap="inferno")
# plot_3d(f_ripple, "Motif sin(x)*cos(y)", cmap="cool")
# plot_3d(f_super_gaussian, "Super-Gaussienne", cmap="magma")
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# Paramètres de la chips
a = 4
b = 4
# Domaine
x = np.linspace(-10, 10, 300)
y = np.linspace(-10, 10, 300)
X, Y = np.meshgrid(x, y)
# Fonction chips (hyperbolic paraboloid)
Z = (X**2 / a**2) - (Y**2 / b**2)
# Tracé
fig = plt.figure(figsize=(10, 7))
ax = fig.add_subplot(111, projection="3d")
surf = ax.plot_surface(X, Y, Z, cmap="plasma", edgecolor="none")
ax.set_title("Surface en forme de chips (Hyperbolic Paraboloid)")
ax.set_xlabel("X")
ax.set_ylabel("Y")
ax.set_zlabel("Z")
fig.colorbar(surf, shrink=0.5, aspect=10)
plt.show()
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
# Domaine
x = np.linspace(-10, 10, 300)
y = np.linspace(-10, 10, 300)
X, Y = np.meshgrid(x, y)
# Première vague sinusoïdale
Z1 = np.sin(np.sqrt(X**2 + Y**2))
# Deuxième vague sinusoïdale (décalée)
Z2 = np.sin(np.sqrt(X**2 + Y**2) + 1.5)
# Figure
fig = plt.figure(figsize=(12, 8))
ax = fig.add_subplot(111, projection="3d")
# Surface 1
ax.plot_surface(
X, Y, Z1,
cmap="cool",
alpha=0.8,
linewidth=0,
antialiased=True
)
# Surface 2
ax.plot_surface(
X, Y, Z2,
cmap="autumn",
alpha=0.8,
linewidth=0,
antialiased=True
)
# Labels
ax.set_title("Deux vagues sinusoïdales en 3D", fontsize=16, fontweight="bold")
ax.set_xlabel("X")
ax.set_ylabel("Y")
ax.set_zlabel("Z")
plt.tight_layout()
plt.show()






Aucun commentaire:
Enregistrer un commentaire