我有一个平面的法线和一个点。我试图把这两个都画出来,但我不认为这是正确的,我也不知道为什么。这是我的密码。你知道吗
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帖子中修改了它。我得到的结果是这样的-
很明显,法线不垂直于平面。你知道吗
但有时它也会起作用,例如当我
point = np.array([1, 2, 3])
normal = np.array([1, 1, 2])
我得到的情节是
显然,这是更好的。第一种情况下怎么不起作用?你知道吗
它看起来很奇怪,因为轴的纵横比。你知道吗
如果将每个轴的范围限制设置为1:1:1,则看起来是垂直的。你知道吗
以下是同一“角度”的1:1而非1:1范围限制的示例:
相关问题 更多 >
编程相关推荐