matlab - 在 Matlab 或 matplotlib 中根据法向量和点绘制平面

标签 matlab matplotlib plot scipy

如何根据法向量和点在 matlab 或 matplotlib 中绘制平面?

最佳答案

对于那里的所有复制/粘贴,这里是使用 matplotlib 的 Python 的类似代码:

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

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

# 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(10), range(10))

# 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)
plt.show()

enter image description here

关于matlab - 在 Matlab 或 matplotlib 中根据法向量和点绘制平面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3461869/

相关文章:

Python - 使用 Ipyvolume 库在 x、y 和 z 轴上绘制不同颜色的问题

r - 我可以阻止 sarima.for 进行绘图吗?

algorithm - SURF 算法的输出到底是什么?我如何使用它们进行分类(SVM 等)?

python - 综合整理 "or"连接的几条语句

java - 识别 "click-point"和 JfreeChart 图中单击的子图时出现问题

python - 如何将 tkinter 与 matplotlib checkbutton 集成以更改变量?

c# - ILSurface 绘图参数

matlab - 我怎样才能在matlab中保存输出?

c - MATLAB C 编码器返回无效

arrays - 确定数组是否包含 Octave 音程中的特定整数