def set_frame_passage_ (list_pt_ref_base, list_pt_ref_ext):
str_erreur = ''
if len(list_pt_ref_base) == len(list_pt_ref_ext):
nb_pts = len(list_pt_ref_base)
array_base = np.zeros((nb_pts, 3))
array_ext = np.zeros((nb_pts, 3))
lg_array = 0
for index in range(0, nb_pts):
array_base[lg_array] = list_pt_ref_base[index][:3]
array_ext[lg_array] = list_pt_ref_ext[index][:3]
lg_array += 1
M = superimposition_matrix(array_base, array_ext, scale=True)
# valeurs de sortie
xyzrpw = set_mat4x4_2_xyzrpw(M)
mat_rdk = mat4x4_numpy_2_rdk(M)
if not (not np.all(M) and xyzrpw and mat_rdk):
return False
return RetVal([True, dt.now, 'matrice de passage calculée avec succès !', M, xyzrpw, mat_rdk])
else:
str_erreur = 'Les tailles du tableau du référentiel base('
str_erreur += str(len(list_pt_ref_base))
str_erreur += ') et du référentiel extérieur('
str_erreur += str(len(list_pt_ref_ext))
str_erreur += ') ne sont pas de la même taille !'
print(str_erreur)
RetVal([False, dt.now, str_erreur])
list_ext_brute = [[406.93, -373.8, 2559.99, 0.0, -0.0, 0.0],
[612.81, -65.74, 2566.76, 0.0, -0.0, 0.0],
[679.68, 520.63, 2542.36, 0.0, -0.0, 0.0],
[271.24, 532.19, 2612.08, 0.0, -0.0, 0.0],
[114.43, -31.73, 2439.24, 0.0, -0.0, 0.0],
[-157.93, -220.7, 2490.9, 0.0, -0.0, 0.0],
[-200.13, -350.38, 2501.29, 0.0, -0.0, 0.0],
[-722.9, -260.64, 2556.52, 0.0, -0.0, 0.0],
[-750.43, 160.15, 2551.35, 0.0, -0.0, 0.0],
[-759.14, 488.8, 2545.55, 0.0, -0.0, 0.0],
[-358.39, 151.63, 2416.5, 0.0, -0.0, 0.0],
[-289.58, -60.31, 2410.38, 0.0, -0.0, 0.0],
[-86.04, 153.06, 2369.19, 0.0, -0.0, 0.0],
[-9.05, -92.79, 2361.71, 0.0, -0.0, 0.0]]
list_base_brute = [[2443.9128, -501.7427, -630.8925, -179.0604, 0.4017, 145.2487],
[2126.8356, -703.2691, -678.1219, -179.6825, 0.552, 124.2606],
[1534.3236, -757.3283, -678.0219, 179.9398, 0.6337, 88.9192],
[1532.8918, -339.4951, -682.6528, 179.7809, 0.5975, 74.2169],
[2103.9974, -226.6539, -472.8035, -179.4523, 0.3239, 153.7627],
[2297.246, 47.3245, -475.6743, -179.4523, 0.3237, 153.7627],
[2429.3814, 88.5478, -476.0224, -179.7454, -0.5832, -109.2463],
[2353.675, 614.8282, -447.7145, -179.7454, -0.5833, -109.2462],
[1931.7996, 651.5278, -448.4745, -179.7454, -0.5835, -109.2461],
[1604.6555, 664.6893, -448.8943, -179.7455, -0.5835, -109.2461],
[1925.4354, 246.4732, -379.1885, -179.7455, -0.5836, -109.2458],
[2137.8614, 172.319, -378.1896, -179.7455, -0.5836, -109.2459],
[1919.7934, -31.8006, -376.11, -179.7455, -0.5837, -109.2459],
[2164.5074, -117.227, -374.9585, -179.7455, -0.5837, -109.2459]]
mat_ = set_frame_passage_(list_base_brute, list_ext_brute)
if mat_.b_done:
print('-------------------------------------------------------------------------------------------------------')
print('xyzrpw = ' + str(mat_.res2))
print('-------------------------------------------------------------------------------------------------------')
print('vecteur translation : x=' + str(mat_.res2[0]) + ', y=' + str(mat_.res2[1]) + ', z=' + str(mat_.res2[2]))
print('angles de rotation : r=' + str(mat_.res2[3]) + ', p=' + str(mat_.res2[4]) + ', w=' + str(mat_.res2[5]))
print('----------------------------------------------------------------------------')
print('Matrice de rotation numpy 4x4:')
print(mat_.res1)
print('----------------------------------------------------------------------------')
print('Matrice de rotation roboDK 4x4:')
print(mat_.res3)
else:
print(mat_.str_msg)