ベクトルのリストがあり、すべてのベクトルと残りのベクトルの間の角度を見つける必要があるコードを作成しようとしています(メディアパイプの手のランドマークに取り組んでいます)。これまでの私のコードは次のとおりです。
vectors = [thumb_cmc_vec, thumb_mcp_vec, thumb_ip_vec, thumb_tip_vec, index_mcp_vec, index_pip_vec,
index_dip_vec, index_tip_vec, middle_mcp_vec, middle_pip_vec, middle_dip_vec, middle_tip_vec,
ring_mcp_vec, ring_pip_vec, ring_dip_vec, ring_tip_vec, pinky_mcp_vec, pinky_pip_vec,
pinky_dip_vec, pinky_tip_vec]
for vector in vectors:
next_vector = vector + 1
print(vector)
for next_vector in vectors:
print(next_vector)
M = (np.linalg.norm(vector) * np.linalg.norm(next_vector))
ES = np.dot(vector, next_vector)
th = math.acos(ES / M)
list.append(th)
print(list)
ここで、M = 現在のベクトル セットのノルムの乗算、ES = ベクトルのスカラー積、th = ベクトルの角度です。next_vector
私の問題は、結果が重複しないように、前のループの次のベクトルから開始したいにもかかわらず、変数が常にリストの最初のベクトルから for ループを開始することです。また、両方のループが 3 番目のベクトル (thumb_ip_vec) にある場合、このエラー
th = math.acos(ES / M) ValueError: math domain error が発生します。これを解決する方法はありますか?ありがとうございました!