У меня 3 точки на плоскости, 3 точки на другой плоскости.Мне нужен угол между плоскостями, поэтому я использую точки, чтобы сделать векторы, скрестить произведение, чтобы найти нормальное, точечное произведение, и поделить на величину и обратное cos, чтобы найти мне угол.
Я ожидал 45 или 0,785398как угол между нормалью плоскостей от точек.Я получаю 0,6154797086703875
В моей логике должно быть что-то не так, может кто-нибудь помочь, пожалуйста?Спасибо.
import numpy as np
"""
y axis up page
x axis to the right on page
z axis towards user out of page
point1 -1,1,0
point2 1,1,0
point3 1,1,1
so horizontal plane at y=1
point4 0,0,0
point5 1,1,0
point6 1,1,1
plane at 45 degrees meeting other plane at 1,1,n
"""
#use points to make vectors
#point2 - point1
vx1 = 2#1--1
vy1 = 0#1-1
vz1 = 0#0-0
#point3 - point1
vx2 = 2#1--1
vy2 = 0#1-1
vz2 = 1#1-0
#cross product to find normal
plane1 = np.cross([vx1,vy1,vz1],[vx2,vy2,vz2])
#use points to make vectors
#point5 - point4
vx1 = 1#1-0
vy1 = 1#1-0
vz1 = 0#0-0
#point6 - point4
vx2 = 1#1-0
vy2 = 1#1-0
vz2 = 1#1-0
#cross product to find normal
plane2 = np.cross([vx1,vy1,vz1],[vx2,vy2,vz2])
#angle between the two normals
#dot product
ang = np.dot(plane1,plane2)
#divide by magnitude of vectors
ang = ang / (np.sqrt((vx1*vx1)+(vy1*vy1)+(vz1*vz1))*np.sqrt((vx2*vx2)+(vy2*vy2)+(vz2*vz2)))
#inverse cos to find angle
ang = np.arccos(ang)
#should be 45 or 0.785398
print("Angle calculated",ang)
if (ang < 95) and (ang > 85):
print("RIGHT ANGLE")
else:
print("OTHER ANGLE")