意外的角度值

问题描述 投票:0回答:1

我有一个坐标为(-51.85,-2.38,-0.93)的向量A。 A 点(我们称之为 Na)的法向量为 (0,0,1)。我想计算位置向量A和法线向量Na之间的角度。直观上,看 A 的坐标和垂直向上的法线,角度应该小于 90。但是,我得到的值大于 90。你能解释一下,为什么会这样,我哪里做错了。请查看随附的代码。

import numpy as np
import math

point_vector = np.array([-51.85,-2.38,-0.93])
normalized_point_vector = point_vector / np.linalg.norm(point_vector)
normal = np.array([0,0,1])
# Normalize the normal vector
normalized_normal = normal / np.linalg.norm(normal)

# Calculate the angle of incidence using the dot product
dot_product = np.dot(normalized_point_vector, normalized_normal)
angle = np.arccos(dot_product)

if angle>math.pi / 2:
   print("angle is:",angle*(180/math.pi))
python math vector geometry physics
1个回答
0
投票

角度应大于90°。将 (0, 0, 1) 与 (-51.85, 0,0) 进行比较,后者的角度恰好为 90°。如果我们现在用 (-51.85, 0, -0.93) 比较 z 值,那么这个 -9.93 指向 (0, 0, 1) 中 1 的相反方向,这将角度从 90° 增加到更大。与y值类似。以 3D 形式想象这两个向量会有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.