save
This commit is contained in:
1 parent
b792f16d23
commit
86d5126345
10 files changed
+98
-131
No files matched your search
Binary file not shown.
Binary file not shown.
@@ -5,7 +5,7 @@
|
|||||||
#place(
|
#place(
|
||||||
dx: -20mm,
|
dx: -20mm,
|
||||||
box(fill: rgb("#171568"), height: 15mm, width: 110%)[
|
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(
|
#place(
|
||||||
dx: -5mm,
|
dx: -5mm,
|
||||||
box(height: 100%, width: 105%)[
|
box(height: 100%, width: 105%)[
|
||||||
#scale(place(image("./image/methamorphose.jpg")), x: 111%)
|
#scale(place(image("./image/methamorphose.jpg"), dx: -1mm), x: 111%)
|
||||||
#place(
|
#place(
|
||||||
dx: -7mm,
|
dx: -7mm,
|
||||||
right + horizon,
|
right + horizon,
|
||||||
@@ -63,9 +63,7 @@
|
|||||||
|
|
||||||
+ La pseudosphère
|
+ La pseudosphère
|
||||||
+ La projection
|
+ La projection
|
||||||
+ Projeté des droites
|
+ Projection des droites
|
||||||
+ Non conservation des longueurs
|
|
||||||
+ Conservation des angles
|
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -117,7 +115,7 @@
|
|||||||
dy: 6cm,
|
dy: 6cm,
|
||||||
figure(
|
figure(
|
||||||
scale(image("./image/pringels.png"), x: 80%, y: 80%),
|
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,9 +156,10 @@
|
|||||||
dx: 7mm,
|
dx: 7mm,
|
||||||
dy: 0mm,
|
dy: 0mm,
|
||||||
$
|
$
|
||||||
P : cases([0; 2pi] times RR_+ &--> " " RR^3,
|
P : cases(
|
||||||
" "(u,v) &arrow.r.long.bar vec( cos(u)/ch(v), sin(u)/ch(v), v - th(v))
|
[0; 2pi] times RR_+ &--> " " RR^3,
|
||||||
)
|
" "(u,v) &arrow.r.long.bar vec(cos(u) / ch(v), sin(u) / ch(v), v - th(v))
|
||||||
|
)
|
||||||
$,
|
$,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -180,7 +179,7 @@
|
|||||||
horizon + left,
|
horizon + left,
|
||||||
dx: 1.5cm,
|
dx: 1.5cm,
|
||||||
dy: -4cm,
|
dy: -4cm,
|
||||||
[On note ] + $display((diff P)/(diff u) = P_u)$,
|
[On note ] + $display((diff P) / (diff u) = P_u)$,
|
||||||
)
|
)
|
||||||
#place(
|
#place(
|
||||||
horizon + left,
|
horizon + left,
|
||||||
@@ -220,7 +219,7 @@
|
|||||||
dy: 13mm,
|
dy: 13mm,
|
||||||
[La courbure en $p in [0; 2pi] times RR_+$]
|
[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)
|
#v(7cm)
|
||||||
@@ -311,12 +310,12 @@ Idée de la projection de Mercator :
|
|||||||
column-gutter: 2cm,
|
column-gutter: 2cm,
|
||||||
align: horizon,
|
align: horizon,
|
||||||
[
|
[
|
||||||
Or : $ B = (diff u)/ch(v) $
|
Or : $ B = (diff u) / ch(v) $
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
Donc
|
Donc
|
||||||
$
|
$
|
||||||
A = cal(E) / B = th(v) diff v
|
A / B = cal(E) / B^2 = sh(v) diff v
|
||||||
$
|
$
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -338,16 +337,36 @@ Idée de la projection de Mercator :
|
|||||||
#{
|
#{
|
||||||
set text(30pt)
|
set text(30pt)
|
||||||
place(
|
place(
|
||||||
center + horizon,
|
dy: 15mm,
|
||||||
|
dx: 2cm,
|
||||||
|
left + top,
|
||||||
|
|
||||||
[
|
[
|
||||||
La projection :
|
La projection :
|
||||||
$
|
$
|
||||||
C : cases([0; 2pi] times RR_+--> RR^2, " " p = (u,v) arrow.long.bar vec(u,ch(v)))
|
C : cases([0; 2pi] times RR_+--> RR^2, " " p = (u,v) arrow.long.bar vec(u, ch(v)))
|
||||||
$
|
$
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
#{
|
||||||
|
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()
|
#pagebreak()
|
||||||
|
|
||||||
@@ -359,17 +378,11 @@ Idée de la projection de Mercator :
|
|||||||
figure(image("./image/cadir.png", width: 40%)),
|
figure(image("./image/cadir.png", width: 40%)),
|
||||||
)
|
)
|
||||||
|
|
||||||
#place(
|
#place($ 1 $, dx: 1.5cm, dy: 15cm)
|
||||||
horizon,
|
#place(sym.arrow.t, dx: 1.2cm)
|
||||||
dx: 2cm,
|
#place($ +oo $, dx: 0.5cm, dy: 0.9cm)
|
||||||
align(
|
#place($0$, dx: 2.04cm, dy: 15.7cm)
|
||||||
center,
|
#place($ 2pi $, dx: 12.2cm, dy: 15.7cm)
|
||||||
text(red, stroke: 0.1pt)[
|
|
||||||
Mettre les bornes de la carte !!\
|
|
||||||
genre $0 -> 2 pi$ et $arrow.t_1^(+oo)$
|
|
||||||
],
|
|
||||||
),
|
|
||||||
)
|
|
||||||
|
|
||||||
#place(
|
#place(
|
||||||
right + horizon,
|
right + horizon,
|
||||||
@@ -395,10 +408,6 @@ Idée de la projection de Mercator :
|
|||||||
|
|
||||||
#pagebreak()
|
#pagebreak()
|
||||||
|
|
||||||
Trouver un moyen pour projter une image
|
|
||||||
|
|
||||||
#pagebreak()
|
|
||||||
|
|
||||||
= 4) Projeté des droites
|
= 4) Projeté des droites
|
||||||
|
|
||||||
#pagebreak()
|
#pagebreak()
|
||||||
@@ -411,9 +420,7 @@ Trouver un moyen pour projter une image
|
|||||||
[
|
[
|
||||||
Équation des droites :
|
Équation des droites :
|
||||||
- Méridiens : $g : t |-> P(u,t)$
|
- Méridiens : $g : t |-> P(u,t)$
|
||||||
- Autres droites : $
|
- Autres droites : $ g : t |-> P(t, ch(sqrt(k^2 - (t + c)^2))) $
|
||||||
g : t |-> P(t, ch(sqrt(k^2 - (t + c)^2)))
|
|
||||||
$
|
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -518,6 +525,9 @@ Trouver un moyen pour projter une image
|
|||||||
|
|
||||||
#pagebreak()
|
#pagebreak()
|
||||||
|
|
||||||
|
== 4) projeté des droites
|
||||||
|
|
||||||
|
|
||||||
#place(
|
#place(
|
||||||
left + horizon,
|
left + horizon,
|
||||||
dx: 1.5cm,
|
dx: 1.5cm,
|
||||||
@@ -536,28 +546,34 @@ Trouver un moyen pour projter une image
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
#pagebreak()
|
|
||||||
|
|
||||||
= 5) Conservation des angles
|
|
||||||
|
|
||||||
#pagebreak()
|
#pagebreak()
|
||||||
|
|
||||||
== 5) conservation des angles
|
== 4) projeté des droites
|
||||||
|
|
||||||
faut que je travaille
|
|
||||||
|
|
||||||
#pagebreak()
|
|
||||||
|
|
||||||
#place(image("image/Tissot.png"))
|
|
||||||
#place(
|
#place(
|
||||||
|
dx: 2cm,
|
||||||
|
image("image/Tissot.png"),
|
||||||
|
)
|
||||||
|
#place(
|
||||||
|
dx: -2cm,
|
||||||
right,
|
right,
|
||||||
image("image/TissotPS.png"),
|
image("image/TissotPS.png"),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#pagebreak()
|
||||||
|
|
||||||
#place(
|
#place(
|
||||||
center + horizon,
|
center + horizon,
|
||||||
[
|
image("prog/merci.png", width: 200%),
|
||||||
Merci\
|
|
||||||
De votre attention
|
|
||||||
],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
#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 |
@@ -1,91 +1,42 @@
|
|||||||
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pygame
|
from mpl_toolkits.mplot3d import Axes3D
|
||||||
from PIL import Image
|
|
||||||
from scipy.interpolate import RegularGridInterpolator
|
|
||||||
|
|
||||||
def pseudo_sphere(u, v):
|
def dec(v):
|
||||||
""" Génère les coordonnées de la pseudo-sphère sans la partie inférieure """
|
if v < 0:
|
||||||
x = np.cos(u) / np.cosh(v)
|
return -np.arccosh(1 - v)
|
||||||
y = np.sin(u) / np.cosh(v)
|
else:
|
||||||
z = v - np.tanh(v)
|
return np.arccosh(v + 1)
|
||||||
return x, y, z
|
|
||||||
|
|
||||||
def project_image_on_pseudo_sphere(image_path, u_res=1000, v_res=1000):
|
# Surface 3D (exemple : une sphère)
|
||||||
""" Projette une image sur la pseudo-sphère avec une nouvelle projection optimisée """
|
theta = np.linspace(0, 2 * np.pi, 500)
|
||||||
# Charger l'image et la faire pivoter de 90°
|
phi = np.linspace(-7, 7, 500)
|
||||||
img = Image.open(image_path).convert('RGB')
|
for i in range(len(phi)):
|
||||||
img = img.rotate(-90, expand=True) # Rotation de 90°
|
phi[i] = dec(phi[i])
|
||||||
img = img.resize((v_res, u_res)) # Réduction de la résolution pour un meilleur rendu
|
print(phi)
|
||||||
img_data = np.array(img)
|
theta, phi = np.meshgrid(theta, phi)
|
||||||
|
r = 1
|
||||||
# Créer la grille de la pseudo-sphère en supprimant la partie inférieure
|
x = r * np.cos(theta) / np.cosh(phi)
|
||||||
u = np.linspace(0, 2 * np.pi, u_res)
|
y = r * np.sin(theta) / np.cosh(phi)
|
||||||
v = np.linspace(0, 2, v_res) # Suppression de la partie inférieure (v > 0)
|
z = phi - np.tanh(phi)
|
||||||
U, V = np.meshgrid(u, v, indexing='ij')
|
|
||||||
X, Y, Z = pseudo_sphere(U, V)
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
# 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
|
# Projection personnalisée (exemple : projection cylindrique)
|
||||||
project_image_on_pseudo_sphere("/home/jvj/gith/typst-file/Typstfile/2nd_annee_prepa/TIPE/image/diffprojS/Equirectangular_projection_SW.jpg")
|
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)
|
||||||
|
]
|
||||||
|
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
plt.savefig("result.png", format="png", dpi=1000)
|
||||||
|
#plt.show()
|
||||||
Reference in new issue
Block a user