绘制平面及其法线

Plotting a plane and its normal

我有一个平面的法线和一个位于其上的点。我正在尝试将这两者都绘制出来,但我不认为这是正确的,我无法弄清楚为什么。这是我的代码。

import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

point  = np.array([1309.66102863, -531.22959263,  341.89779288])
normal = np.array([ 80.60165306, -32.69394323,  21.04172506])

# a plane is a*x+b*y+c*z+d=0
# [a,b,c] is the normal. Thus, we have to calculate
# d and we're set
d = -point.dot(normal)

# create x,y
xx, yy = np.meshgrid(range(1200,1400), range(-600,-400))

# calculate corresponding z
z = (-normal[0] * xx - normal[1] * yy - d) * 1. /normal[2]

# plot the surface
plt3d = plt.figure().gca(projection='3d')
plt3d.plot_surface(xx, yy, z, alpha=0.2)
plt3d.plot([point[0], point[0]+normal[0]], 
           [point[1], point[1]+normal[1]], 
           [point[2], point[2]+normal[2]])
plt.show()

我修改自this post。我得到的结果看起来像这样 -

显然法线不垂直于平面。

但有时它会起作用,例如当我设置

point  = np.array([1, 2, 3])
normal = np.array([1, 1, 2])

我得到的情节是

显然这要好得多。怎么在第一种情况下不起作用?

由于轴的纵横比,看起来很奇怪。

如果将每个轴的范围限制设置为 1:1:1,它将看起来垂直。

这里是 1:1 的示例,而不是相同 "angle" 的 1:1 范围限制: