L'installation Elasticité dynamique agit comme un filtre et génère de nouveaux espaces démultipliés, comme un empilement quasi infini d'horizons. Par principe de réflexion, la pièce absorbe l'image de l'environnement et accumule les points de vue ; le mouvement permanent requalifie continuellement ce qui est regardé et entendu.

Ce post étudie quelques principes fondamentaux relatifs à des reflections mutliples dans des mirroirs.

In [1]:
%load_ext autoreload
%autoreload 2
In [2]:
import elasticite as el
import numpy as np
duration = el.get_default_args(el.EdgeGrid.render)['duration']
/usr/local/lib/python3.5/site-packages/matplotlib/__init__.py:872: UserWarning: axes.color_cycle is deprecated and replaced with axes.prop_cycle; please use the latter.
  warnings.warn(self.msg_depr % (key, alt_key))
In [3]:
import sys
sys.path.append('..')
from scenario_line_fresnel import EdgeGrid
e = EdgeGrid(N_lame=25, grid_type='line')
In [4]:
e.lames.shape
Out[4]:
(4, 31)
In [5]:
%matplotlib inline
%config InlineBackend.figure_format='retina'
#%config InlineBackend.figure_format = 'svg'
import matplotlib.pyplot as plt
import numpy as np
np.set_printoptions(precision=2, suppress=True)
In [6]:
particles = np.array([[.2, .3], [-.5, 1.1], [.3, .9]]).T
fig = plt.figure(figsize=(5, 5))
border = 0.0
ax = fig.add_axes((border, border, 1.-2*border, 1.-2*border), axisbg='w')
ax.plot(particles[0, 0], particles[1, 0], 'b+')
ax.plot(particles[0, 1:], particles[1, 1:], 'r')
ax.set_xlim([-1, 1])
ax.set_ylim([0, 2])
print(particles)
[[ 0.2 -0.5  0.3]
 [ 0.3  1.1  0.9]]

projection du point sur la droite

In [7]:
particles = np.array([[.2, 1.4], [-.5, 1.], [.4, 1.]]).T
particles = np.array([[.2, 1.5], [-.5, .8], [.3, .9]]).T
print(particles)
P = particles[:, 0].copy()
print(P)
print(np.dot(particles[:, 1:].T, np.array([[0, 1], [-1, 0]])))
perp = np.zeros_like(P)
perp[0] = particles[1, 2] - particles[1, 1]
perp[1] = -(particles[0, 2] - particles[0, 1])
print(perp)
# distance to the line
d = perp[0]*(particles[0, 1] - particles[0, 0]) + perp[1]*(particles[1, 1] - particles[1, 0])
print(d, np.sqrt(perp[0]**2 + perp[1]**2), d/np.sqrt(perp[0]**2 + perp[1]**2))
# normalizing
#perp /= np.sqrt((perp**2).sum())
#perp /= np.sqrt(perp[0]**2 + perp[1]**2)
P += d * perp / (perp[0]**2 + perp[1]**2)
fig = plt.figure(figsize=(5, 5))
border = 0.0
ax = fig.add_axes((border, border, 1.-2*border, 1.-2*border), axisbg='w')
ax.plot(particles[0, 0], particles[1, 0], 'b+')
ax.plot(particles[0, 1:], particles[1, 1:], 'r')
ax.plot(P[0], P[1], 'gs')
ax.set_xlim([-1, 1])
ax.set_ylim([0, 2])
print(P)
[[ 0.2 -0.5  0.3]
 [ 1.5  0.8  0.9]]
[ 0.2  1.5]
[[-0.8 -0.5]
 [-0.9  0.3]]
[ 0.1 -0.8]
0.49 0.80622577483 0.607770199487
[ 0.28  0.9 ]

shorter form

In [8]:
particles = np.array([[.2, 1.4], [-.5, 1.], [.4, 1.]]).T
particles = np.array([[.2, 1.5], [-.5, .8], [.3, .9]]).T
perp = np.array([particles[1, 2] - particles[1, 1], -(particles[0, 2] - particles[0, 1])])
# distance to the line
d = perp[0]*(particles[0, 1] - particles[0, 0]) + perp[1]*(particles[1, 1] - particles[1, 0])
P =  particles[:, 0] + d * perp / (perp**2).sum()

fig = plt.figure(figsize=(5, 5))
border = 0.0
ax = fig.add_axes((border, border, 1.-2*border, 1.-2*border), axisbg='w')
ax.plot(particles[0, 0], particles[1, 0], 'b+')
ax.plot(particles[0, 1:], particles[1, 1:], 'r')
ax.plot(P[0], P[1], 'gs')
ax.set_xlim([-1, 1])
ax.set_ylim([0, 2])
print(P)
[ 0.28  0.9 ]

deducing the mirror image as twice this projection

In [9]:
particles = np.array([[.2, 1.4], [-.5, 1.], [.4, 1.]]).T
particles = np.array([[.2, 1.5], [-.5, .8], [.3, .9]]).T
perp = np.array([particles[1, 2] - particles[1, 1], -(particles[0, 2] - particles[0, 1])])
# distance to the line
d = perp[0]*(particles[0, 1] - particles[0, 0]) + perp[1]*(particles[1, 1] - particles[1, 0])
P =  particles[:, 0] + 2 *d * perp / (perp**2).sum()

fig = plt.figure(figsize=(5, 5))
border = 0.0
ax = fig.add_axes((border, border, 1.-2*border, 1.-2*border), axisbg='w')
ax.plot(particles[0, 0], particles[1, 0], 'b+')
ax.plot(particles[0, 1:], particles[1, 1:], 'r')
ax.plot(P[0], P[1], 'gs')
ax.set_xlim([-1, 1])
ax.set_ylim([0, 2])
print(P)
[ 0.35  0.29]

a function

In [10]:
particles.T.tolist()
Out[10]:
[[0.2, 1.5], [-0.5, 0.8], [0.3, 0.9]]
In [11]:
particles = np.array([[-.5, .5],[.2, 1.5], [-.5, .8], [.3, .9]]).T
particles = np.random.rand(2, 10)
print(particles)
segment = np.array([[-.5, .5], [.5, 1.5]]).T
print(segment)
def mirror(particles, segment, alpha=1.):
    mirror = particles.copy()
    perp = np.array([segment[1][1] - segment[1][0], -(segment[0][1] - segment[0][0])])
    # distance to the line
    d = perp[0]*(segment[0][1] - particles[0, :]) + perp[1]*(segment[1, 1] - particles[1, :])
    mirror[:2, :] =  particles[:2, :] + 2. * d[np.newaxis, :] * perp[:, np.newaxis] / (perp**2).sum()
    if mirror.shape[0]>2: mirror[2, :] =  alpha * particles[2, :]
    #ind = 1-(d == np.zeros_like(d))
    return mirror#[:, ind]

particles_mirror = mirror(particles, segment)

fig = plt.figure(figsize=(5, 5))
border = 0.0
ax = fig.add_axes((border, border, 1.-2*border, 1.-2*border), axisbg='w')
ax.plot(particles[0, :], particles[1, :], 'b+')
ax.plot(segment[0, :], segment[1, :], 'r')
ax.plot(particles_mirror[0, :], particles_mirror[1, :], 'g+')
ax.plot(np.vstack((particles[0, :], particles_mirror[0, :])), np.vstack((particles[1, :], particles_mirror[1, :])), 'k--')
ax.set_xlim([-1, 1])
ax.set_ylim([0, 2])
print(particles_mirror)
[[ 0.5   0.12  0.85  0.5   0.64  0.91  0.58  0.35  0.58  0.67]
 [ 0.81  0.02  0.62  0.04  0.89  0.29  0.94  0.94  0.38  0.81]]
[[-0.5  0.5]
 [ 0.5  1.5]]
[[-0.19 -0.98 -0.38 -0.96 -0.11 -0.71 -0.06 -0.06 -0.62 -0.19]
 [ 1.5   1.12  1.85  1.5   1.64  1.91  1.58  1.35  1.58  1.67]]

miroir d'une image et image d'un miroir

peut on simuler de façon équivalente plusieurs reflections en utilisant le miroir d'un segment

In [12]:
particles = np.array([[-.5, .5],[.2, 1.5], [-.5, .8], [.3, .9]]).T
particles = np.random.rand(2, 10)
print(particles)
segmentA = np.array([[-.5, .5], [.5, 1.5]]).T
segmentB = np.array([[-0., 0.], [.0, 2.]]).T
print(segmentA, segmentB)

particles_mirrorA = mirror(particles, segmentA)
particles_mirrorAB = mirror(particles_mirrorA, segmentB)
segmentB_mirrorA = mirror(segmentA, segmentB)
particles_mirrorAB_ = mirror(particles, segmentB_mirrorA)

fig = plt.figure(figsize=(15, 15))
border = 0.0
ax = fig.add_axes((border, border, 1.-2*border, 1.-2*border), axisbg='w')
ax.plot(particles[0, :], particles[1, :], 'bo')
ax.plot(segmentA[0, :], segmentA[1, :], 'r')
ax.plot(segmentB[0, :], segmentB[1, :], 'b')
ax.plot(segmentB_mirrorA[0, :], segmentB_mirrorA[1, :], 'b--')
ax.plot(particles_mirrorA[0, :], particles_mirrorA[1, :], 'go')
ax.plot(particles_mirrorAB[0, :], particles_mirrorAB[1, :], 'g+')
ax.plot(particles_mirrorAB_[0, :], particles_mirrorAB_[1, :], 'gx')
ax.plot(np.vstack((particles_mirrorA[0, :], particles_mirrorAB[0, :])), np.vstack((particles_mirrorA[1, :], particles_mirrorAB[1, :])), 'k--')
ax.plot(np.vstack((particles[0, :], particles_mirrorAB_[0, :])), np.vstack((particles[1, :], particles_mirrorAB_[1, :])), 'k-.')
ax.set_xlim([-1, 1])
ax.set_ylim([0, 2])
print(particles_mirror)
[[ 0.31  0.97  0.45  0.7   0.06  0.21  0.24  0.25  0.68  0.76]
 [ 0.46  0.01  0.76  0.81  0.8   0.25  0.18  0.78  0.37  0.44]]
[[-0.5  0.5]
 [ 0.5  1.5]] [[-0.  0.]
 [ 0.  2.]]
[[-0.19 -0.98 -0.38 -0.96 -0.11 -0.71 -0.06 -0.06 -0.62 -0.19]
 [ 1.5   1.12  1.85  1.5   1.64  1.91  1.58  1.35  1.58  1.67]]

on applique maintenant à la structure

la structure est représentée par une liste de segments sur lesquels on a tiré des points

In [13]:
import elasticite as el
import numpy as np

e = el.EdgeGrid(N_lame=25, grid_type='line')
e.sample_structure()
fig, ax = e.plot_structure()
print(e.do_structure())
[[-1.45 -3.53 -3.85  1.45  3.53  3.85]
 [ 3.11  1.36 -1.46  3.11  1.36 -1.46]
 [ 3.4   4.28  4.92 -0.26 -1.13 -1.78]]
In [14]:
segments = e.structure_as_segments()
print(segments)
[array([[ 0.  , -2.9 ],
       [ 3.5 ,  2.72]]), array([[-2.9 , -4.17],
       [ 2.72,  0.  ]]), array([[-4.17, -3.54],
       [ 0.  , -2.93]]), array([[ 0.  ,  2.9 ],
       [ 3.5 ,  2.72]]), array([[ 2.9 ,  4.17],
       [ 2.72,  0.  ]]), array([[ 4.17,  3.54],
       [ 0.  , -2.93]])]
In [15]:
e = el.EdgeGrid(N_lame=25, grid_type='line')
e.sample_structure()
alpha = .8
particles = e.particles.copy()
particles_mirror = particles.copy()
for segment in segments:
    particles_mirror = np.hstack((particles_mirror, mirror(particles, segment, alpha)))
    #print(particles_mirror.shape)#, mirror(e.particles, np.array(segment))).shape)

e.particles = particles_mirror
fig, ax = e.plot_structure()
In [16]:
alpha *= .8
particles = e.particles.copy()
particles_mirror = particles.copy()
for segment in segments:
    particles_mirror = np.hstack((particles_mirror, mirror(particles, np.array(segment), alpha)))
    #print(particles_mirror.shape)#, mirror(e.particles, np.array(segment))).shape)

e.particles = particles_mirror
fig, ax = e.plot_structure()
In [17]:
alpha *= .8
particles = e.particles.copy()
particles_mirror = particles.copy()
for segment in segments:
    particles_mirror = np.hstack((particles_mirror, mirror(particles, np.array(segment), alpha)))
    #print(particles_mirror.shape)#, mirror(e.particles, np.array(segment))).shape)

    
e.total_width *= 1.6
e.particles = particles_mirror
fig, ax = e.plot_structure()

Summming up everything in a few functions:

In [18]:
e = el.EdgeGrid(N_lame=25, grid_type='line')
e.sample_structure()
fig, ax = e.plot_structure()
In [19]:
e = el.EdgeGrid(N_lame=25, grid_type='line')
e.sample_structure(N_mirror=1, alpha = .8)
e.total_width *= 1.6
fig, ax = e.plot_structure()
In [20]:
e = el.EdgeGrid(N_lame=25, grid_type='line')
e.sample_structure(N_mirror=2, alpha = .8)
fig, ax = e.plot_structure()