This commit is contained in:
Le_Foucheur committed 2025-05-20 15:21:54 +02:00
1 parent b792f16d23
commit 86d5126345
10 files changed
+91 -124

No files matched your search

Binary file not shown.
Binary file not shown.
+55 -39
View File
@@ -5,7 +5,7 @@
#place(
dx: -20mm,
box(fill: rgb("#171568"), height: 15mm, width: 110%)[
#place(dx: -5mm, right + horizon, [#h(18mm) Gaspar Daguet, n=°XXXXXXX])
#place(dx: -5mm, right + horizon, [#h(18mm) Gaspar Daguet, n=°21528])
],
)
],
@@ -15,7 +15,7 @@
#place(
dx: -5mm,
box(height: 100%, width: 105%)[
#scale(place(image("./image/methamorphose.jpg")), x: 111%)
#scale(place(image("./image/methamorphose.jpg"), dx: -1mm), x: 111%)
#place(
dx: -7mm,
right + horizon,
@@ -63,9 +63,7 @@
+ La pseudosphère
+ La projection
+ Projeté des droites
+ Non conservation des longueurs
+ Conservation des angles
+ Projection des droites
]
@@ -117,7 +115,7 @@
dy: 6cm,
figure(
scale(image("./image/pringels.png"), x: 80%, y: 80%),
caption: place(center + bottom, dy: -7mm, text(20pt)[un pringle]),
caption: place(center + bottom, dy: -7mm, text(20pt)[une chips]),
),
)
@@ -158,7 +156,8 @@
dx: 7mm,
dy: 0mm,
$
P : cases([0; 2pi] times RR_+ &--> " " RR^3,
P : cases(
[0; 2pi] times RR_+ &--> " " RR^3,
" "(u,v) &arrow.r.long.bar vec(cos(u) / ch(v), sin(u) / ch(v), v - th(v))
)
$,
@@ -220,7 +219,7 @@
dy: 13mm,
[La courbure en $p in [0; 2pi] times RR_+$]
+ $
K(p) = (cal(L)(p)cal(N)(p) - cal(M)(p)^2) / (E(p)G(p) - F^2)
K(p) = (cal(L)(p)cal(N)(p) - cal(M)(p)^2) / (E(p)G(p) - F(p)^2)
$,
)
#v(7cm)
@@ -316,7 +315,7 @@ Idée de la projection de Mercator :
[
Donc
$
A = cal(E) / B = th(v) diff v
A / B = cal(E) / B^2 = sh(v) diff v
$
],
),
@@ -338,7 +337,9 @@ Idée de la projection de Mercator :
#{
set text(30pt)
place(
center + horizon,
dy: 15mm,
dx: 2cm,
left + top,
[
La projection :
@@ -348,6 +349,24 @@ Idée de la projection de Mercator :
],
)
}
#{
set text(30pt)
place(
dy: -15mm,
dx: 2cm,
left + bottom,
[
Celle de Mercator :
$
M: cases([0;2pi] times [-pi;pi] --> RR^2, p = (u,v) arrow.long.bar vec(u, ln(tan(v / 2 + pi / 4))))
$
],
)
}
#place(
right + horizon,
image("image/projTerrePS.png", height: 18cm),
)
#pagebreak()
@@ -359,17 +378,11 @@ Idée de la projection de Mercator :
figure(image("./image/cadir.png", width: 40%)),
)
#place(
horizon,
dx: 2cm,
align(
center,
text(red, stroke: 0.1pt)[
Mettre les bornes de la carte !!\
genre $0 -> 2 pi$ et $arrow.t_1^(+oo)$
],
),
)
#place($ 1 $, dx: 1.5cm, dy: 15cm)
#place(sym.arrow.t, dx: 1.2cm)
#place($ +oo $, dx: 0.5cm, dy: 0.9cm)
#place($0$, dx: 2.04cm, dy: 15.7cm)
#place($ 2pi $, dx: 12.2cm, dy: 15.7cm)
#place(
right + horizon,
@@ -395,10 +408,6 @@ Idée de la projection de Mercator :
#pagebreak()
Trouver un moyen pour projter une image
#pagebreak()
= 4) Projeté des droites
#pagebreak()
@@ -411,9 +420,7 @@ Trouver un moyen pour projter une image
[
Équation des droites :
- Méridiens : $g : t |-> P(u,t)$
- Autres droites : $
g : t |-> P(t, ch(sqrt(k^2 - (t + c)^2)))
$
- Autres droites : $ g : t |-> P(t, ch(sqrt(k^2 - (t + c)^2))) $
],
)
@@ -518,6 +525,9 @@ Trouver un moyen pour projter une image
#pagebreak()
== 4) projeté des droites
#place(
left + horizon,
dx: 1.5cm,
@@ -536,28 +546,34 @@ Trouver un moyen pour projter une image
),
)
#pagebreak()
= 5) Conservation des angles
#pagebreak()
== 5) conservation des angles
== 4) projeté des droites
faut que je travaille
#pagebreak()
#place(image("image/Tissot.png"))
#place(
dx: 2cm,
image("image/Tissot.png"),
)
#place(
dx: -2cm,
right,
image("image/TissotPS.png"),
)
#pagebreak()
#place(
center + horizon,
[
Merci\
De votre attention
],
image("prog/merci.png", width: 200%),
)
#pagebreak()
= Annexes
#pagebreak()
== Annexes
Binary file not shown.
Binary file not shown.

After

Width:  |  Height:  |  Size: 746 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 KiB

+36 -85
View File
@@ -1,91 +1,42 @@
import matplotlib.pyplot as plt
import numpy as np
import pygame
from PIL import Image
from scipy.interpolate import RegularGridInterpolator
from mpl_toolkits.mplot3d import Axes3D
def pseudo_sphere(u, v):
""" Génère les coordonnées de la pseudo-sphère sans la partie inférieure """
x = np.cos(u) / np.cosh(v)
y = np.sin(u) / np.cosh(v)
z = v - np.tanh(v)
return x, y, z
def dec(v):
if v < 0:
return -np.arccosh(1 - v)
else:
return np.arccosh(v + 1)
def project_image_on_pseudo_sphere(image_path, u_res=1000, v_res=1000):
""" Projette une image sur la pseudo-sphère avec une nouvelle projection optimisée """
# Charger l'image et la faire pivoter de 90°
img = Image.open(image_path).convert('RGB')
img = img.rotate(-90, expand=True) # Rotation de 90°
img = img.resize((v_res, u_res)) # Réduction de la résolution pour un meilleur rendu
img_data = np.array(img)
# Surface 3D (exemple : une sphère)
theta = np.linspace(0, 2 * np.pi, 500)
phi = np.linspace(-7, 7, 500)
for i in range(len(phi)):
phi[i] = dec(phi[i])
print(phi)
theta, phi = np.meshgrid(theta, phi)
r = 1
x = r * np.cos(theta) / np.cosh(phi)
y = r * np.sin(theta) / np.cosh(phi)
z = phi - np.tanh(phi)
# Créer la grille de la pseudo-sphère en supprimant la partie inférieure
u = np.linspace(0, 2 * np.pi, u_res)
v = np.linspace(0, 2, v_res) # Suppression de la partie inférieure (v > 0)
U, V = np.meshgrid(u, v, indexing='ij')
X, Y, Z = pseudo_sphere(U, V)
# Projection personnalisée (exemple : projection cylindrique)
image = plt.imread("/home/jvj/Telechargements/merci.jpg")
u = (theta - np.min(theta)) / (np.max(theta) - np.min(theta)) # Normalisation
v = (phi - np.min(phi)) / (np.max(phi) - np.min(phi))
image = image[::-1]
texture = image[
(v * (image.shape[0] - 1)).astype(int), (u * (image.shape[1] - 1)).astype(int)
]
# Nouvelle projection de l'image
u_norm = (U - U.min()) / (U.max() - U.min())
v_norm = (np.cosh(V) - np.cosh(V).min()) / (np.cosh(V).max() - np.cosh(V).min())
points = np.array([u_norm.flatten(), v_norm.flatten()]).T
# Affichage
fig = plt.figure()
ax: Axes3D = fig.add_subplot(111, projection="3d")
ax.set_axis_off()
ax.view_init(elev=4, azim=-180, roll=0)
ax.set_xlim(-3, 3)
ax.set_ylim(-3, 3)
ax.plot_surface(x, y, z, facecolors=texture / 255.0, rstride=1, cstride=1)
# Création de l'interpolateur d'image
u_idx = np.linspace(0, 1, u_res)
v_idx = np.linspace(0, 1, v_res)
interpolator_r = RegularGridInterpolator((u_idx, v_idx), img_data[:, :, 0])
interpolator_g = RegularGridInterpolator((u_idx, v_idx), img_data[:, :, 1])
interpolator_b = RegularGridInterpolator((u_idx, v_idx), img_data[:, :, 2])
colors = np.zeros((u_res * v_res, 3), dtype=np.uint8)
colors[:, 0] = interpolator_r(points)
colors[:, 1] = interpolator_g(points)
colors[:, 2] = interpolator_b(points)
colors = colors.reshape((u_res, v_res, 3))
# Initialiser pygame
pygame.init()
screen = pygame.display.set_mode((600, 600))
pygame.display.set_caption("Projection sur Pseudo-Sphère")
clock = pygame.time.Clock()
angle_x, angle_y = 0, 0
# Affichage de la projection avec rotation optimisée
running = True
while running:
screen.fill((0, 0, 0))
rot_x = np.array([[1, 0, 0], [0, np.cos(angle_x), -np.sin(angle_x)], [0, np.sin(angle_x), np.cos(angle_x)]])
rot_y = np.array([[np.cos(angle_y), 0, np.sin(angle_y)], [0, 1, 0], [-np.sin(angle_y), 0, np.cos(angle_y)]])
pixels = pygame.PixelArray(screen)
for i in range(u_res):
for j in range(v_res):
vec = np.array([X[i, j], Y[i, j], Z[i, j]])
vec = rot_x @ vec
vec = rot_y @ vec
x, y = int((vec[0] + 1) * 300), int((vec[1] + 1) * 300)
if 0 <= x < 600 and 0 <= y < 600:
pixels[x, y] = tuple(colors[i, j])
del pixels # Libérer les pixels pour appliquer les modifications
pygame.display.flip()
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
angle_y -= 0.1
if event.key == pygame.K_RIGHT:
angle_y += 0.1
if event.key == pygame.K_UP:
angle_x -= 0.1
if event.key == pygame.K_DOWN:
angle_x += 0.1
clock.tick(60) # Augmentation du taux de rafraîchissement
pygame.quit()
# Exemple d'utilisation
project_image_on_pseudo_sphere("/home/jvj/gith/typst-file/Typstfile/2nd_annee_prepa/TIPE/image/diffprojS/Equirectangular_projection_SW.jpg")
plt.savefig("result.png", format="png", dpi=1000)
#plt.show()