python - 在 matplotlib 3d 中旋转 stl 文件
问题描述
我正在使用 numpy-stl 在绘图中打开 stl 文件。它是打开的 stl 文件。但我有一个问题。我想像这样在图中旋转 stl 文件:
代码在这里:
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()
解决方案
我解决了这个问题。如果您对 numpy-stl 旋转问题或其他问题有疑问,可以毫不犹豫地问我。这是我的解决方案:
self.m1 = mesh.Mesh.from_file('assets/file.stl')
self.m1.rotate([x-axis, y-axis, z-axis], math.radians(angle))
代码:
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))
推荐阅读
- javascript - 在 Ionic Angular 应用程序中从 Firebase 数据库查询的“Where”子句放在哪里?
- reactjs - 如何在 redux 中获得以前的状态?
- php - 如何编辑我的代码以将小数分隔符从点更改为逗号。(文本包含在输出中)
- qlikview - QMC 服务器问题:不允许打开 QVS@servername 的任何选项卡
- database - 在 MySQL 中的到期日期前 1 个月从数据库发送电子邮件
- sql - 如何知道 a 列是否包含所有 NULL
- sql - 暂存表查询以表形式返回
- r - 变异列以检测变体的数量
- android - 在 webview 上的加载条件下 onBackPress 应用程序崩溃
- node.js - 如何构建节点 js 应用程序?