首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在matplotlib 3d中旋转stl文件

在matplotlib 3d中旋转stl文件
EN

Stack Overflow用户
提问于 2020-04-18 02:07:13
回答 1查看 703关注 0票数 0

我使用numpy-stl打开绘图中的stl文件。它是打开stl文件。但我有个问题。我想在绘图中旋转stl文件,如下图所示:

代码如下:

代码语言:javascript
复制
from stl import mesh
from mpl_toolkits import mplot3d
from matplotlib import pyplot
from math import sin,cos,pi
import numpy as np

# Create a new plot
figure = pyplot.figure()
axes = mplot3d.Axes3D(figure)

m1 = mesh.Mesh.from_file('filea.stl')
axes.add_collection3d(mplot3d.art3d.Poly3DCollection(m1.vectors))

# Auto scale to the mesh size
scale = m1.points.flatten()
axes.auto_scale_xyz(scale-10, scale+10, scale)

# Show the plot to the screen
pyplot.show()
EN

回答 1

Stack Overflow用户

发布于 2021-01-20 19:29:00

我解决了这个问题。如果你有关于numpy-stl旋转问题或其他问题的问题,你可以毫不犹豫地问我。以下是我的解决方案:

代码语言:javascript
复制
self.m1 = mesh.Mesh.from_file('assets/file.stl')
self.m1.rotate([x-axis, y-axis, z-axis], math.radians(angle))

代码:

代码语言:javascript
复制
self.m1.rotate([1, 0, 0], math.radians(angleinxaxis))
self.m1.rotate([0, 1, 0], math.radians(angleinyaxis))
self.m1.rotate([0, 0, 1], math.radians(angleinzaxis))
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61277936

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档