The image attached gives the code of the cuboid。 `##定义绘制长方体 def plot_cuboid(中心,大小): “” 创建用于长方体绘制的数据数组。
============= ================================================
Argument Description
============= ================================================
center center of the cuboid, triple
size size of the cuboid, triple, (x_length,y_width,z_height)
:type size: tuple, numpy.array, list
:param size: size of the cuboid, triple, (x_length,y_width,z_height)
:type center: tuple, numpy.array, list
:param center: center of the cuboid, triple, (x,y,z)
# suppose axis direction: x: to left; y: to inside; z: to upper
# get the (left, outside, bottom) point
ox, oy, oz = center
l, w, h = size
##defining the points
x = np.linspace(ox-l/2,ox+l/2,num=10)
y = np.linspace(oy-w/2,oy+w/2,num=10)
z = np.linspace(oz-h/2,oz+h/2,num=10)
## defining surfaces and extrude them
x1, z1 = np.meshgrid(x, z)
y11 = np.ones_like(x1)*(oy-w/2)
y12 = np.ones_like(x1)*(oy+w/2)
x2, y2 = np.meshgrid(x, y)
z21 = np.ones_like(x2)*(oz-h/2)
z22 = np.ones_like(x2)*(oz+h/2)
y3, z3 = np.meshgrid(y, z)
x31 = np.ones_like(y3)*(ox-l/2)
x32 = np.ones_like(y3)*(ox+l/2)
ax = fig.gca(projection='3d') ##plot the project cuboid
#plot outside surface
ax.plot_surface(x1, y11, z1, color='red', rstride=1, cstride=1, alpha=0.6)
#plot inside surface
ax.plot_surface(x1, y12, z1, color='white', rstride=1, cstride=1, alpha=0.6)
#plot bottom surface
ax.plot_surface(x2, y2, z21, color='blue', rstride=1, cstride=1, alpha=0.6)
#plot upper surface
ax.plot_surface(x2, y2, z22, color='black', rstride=1, cstride=1, alpha=0.6)
#plot left surface
ax.plot_surface(x31, y3, z3, color='green', rstride=1, cstride=1, alpha=0.6)
#plot right surface
ax.plot_surface(x32, y3, z3, color='pink', rstride=1, cstride=1, alpha=0.6)
## Add title
plt.title('Plot_for_PSM', fontsize=20)
##labelling the axes
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
`
我的问题是,我们可以用python中的欧拉角旋转下面定义的长方体吗?
center =(2.1,-0.1,0.757761) 长= 0.3,宽= 0.4,高= 0.1,均以米为单位。 按照所附图片中的代码。 欧拉角沿x,y,z方向的角度例如为0,0,120。
我已经编写了一些程序来旋转具有欧拉角的长方体。但是,在达到欧拉角后,如何旋转长方体是我的问题。谁能建议或获得解决此问题的代码?
实际上,我有四元数,这些四元数被转换为欧拉角,然后要用这些右欧拉定律根据这些欧拉角沿其轴旋转。您可以查看我的代码,直到完成为止,也可以建议我做错了什么。
在代码中,“ y”代表与x轴的夹角,“ p”代表与y轴的夹角,“ r”代表与z轴的夹角。预期结果是长方体必须相对于x,y,z轴沿这些欧拉角(y,p,r)旋转。
谢谢!
答案 0 :(得分:0)
首先计算拐角的位置矢量(xyz坐标),然后在每个拐角上使用int recordCount = Integer.parseInf(m.get("recordCount"));
for(int i =0 ;i<recordCount;i++)
{
System.out.println("First Name :" + m.get("firstname"+i));
}
。