[ 3 / biz / cgl / ck / diy / fa / ic / jp / lit / sci / vr / vt ] [ index / top / reports ] [ become a patron ] [ status ]
2023-11: Warosu is now out of extended maintenance.

/sci/ - Science & Math

Search:


View post   

>> No.10357748 [View]
File: 49 KB, 814x687, cube.png [View same] [iqdb] [saucenao] [google]
10357748

>>10356870

This is the right answer. Here is some python code:


import numpy as np
import matplotlib.pyplot as plt

#calc distance but mask for the shape of the cube
def calcDistance(x1, y1, x2, y2):
return np.where(np.logical_or(np.logical_or(np.logical_and(x1 < 2, y1<2),np.logical_and(x1 >3,y1 < 2)),np.logical_or(np.logical_and(x1 >3,y1 > 3),np.logical_and(x1 <2,y1 > 3))),0,np.sqrt((x1-x2)**2+(y1-y2)**2))

x = np.linspace(0,6,601)
y = np.linspace(0,5,501)

x2, y2 = np.meshgrid(x,y)

#take into account that the cube repeats by calculating the distance to B
#from all points of the base
z1 = calcDistance(x2,y2,2,2)
z2 = calcDistance(x2,y2,2,3)
z3 = calcDistance(x2,y2,3,2)
z4 = calcDistance(x2,y2,3,3)
#now the the minimum of all these distances, the shortest path is the one we take
z12 = np.minimum(z1,z2)
z34 = np.minimum(z3,z4)
z1234 = np.minimum(z12,z34)

plt.figure()
plt.pcolormesh(x2,y2,z1234)
plt.gca().set_aspect("equal")
plt.show()

print(np.unravel_index(z1234.argmax(), z1234.shape))

=> prints (600,250), i.e. the point >>10356870 marked.

Navigation
View posts[+24][+48][+96]