作者:杨颖
链接:http://www.zhihu.com/question/23745611/answer/25530070
来源:知乎
著作权归作者所有,转载请联系作者获得授权。
说下方法。
这里生成3Dplot和matlab一样
在
ax.plot_surface(X, Y, Zs, rstride=6, cstride=6, alpha=0.4,cmap=cm.cool)
中的,X,Y都是网格采样点
直观看就是平铺在X-Y平面的网点
X为
array([[-100. , -99.5, -99. , ..., 98.5, 99. , 99.5],
[-100. , -99.5, -99. , ..., 98.5, 99. , 99.5],
[-100. , -99.5, -99. , ..., 98.5, 99. , 99.5],
...,
[-100. , -99.5, -99. , ..., 98.5, 99. , 99.5],
[-100. , -99.5, -99. , ..., 98.5, 99. , 99.5],
[-100. , -99.5, -99. , ..., 98.5, 99. , 99.5]])
Y为
array([[-100. , -100. , -100. , ..., -100. , -100. , -100. ],
[ -99.5, -99.5, -99.5, ..., -99.5, -99.5, -99.5],
[ -99. , -99. , -99. , ..., -99. , -99. , -99. ],
...,
[ 98.5, 98.5, 98.5, ..., 98.5, 98.5, 98.5],
[ 99. , 99. , 99. , ..., 99. , 99. , 99. ],
[ 99.5, 99.5, 99.5, ..., 99.5, 99.5, 99.5]])
所以这里一共有400个输入点
旋转时要分别用每个拿肆昌点乘以旋转矩阵
其中B为rotation matrix
注意旋转矩阵需要是正交矩阵,这样图形旋转后图形大小不会改变,因为一个向量乘以旋转矩阵只雹枯改变方向消扒不改变大小。