python读取stl文件三维坐标_在Python中从STL文件渲染2D图像

本文介绍如何使用numpy-stl和vtkplotlib库在Python中读取STL文件并生成2D图像,同时探讨如何通过添加光照效果来增强图像细节。原始代码仅显示了组件轮廓,而通过引入vtkplotlib,可以更方便地展示STL模型并调整颜色。
摘要由CSDN通过智能技术生成

I would like to load an STL file and produce a set of 2D images in different rotations.

I got the basics working with numpy-stl based on this example, ended up with this code -

from stl import mesh

from mpl_toolkits import mplot3d

from matplotlib import pyplot

filename = '3001.stl'

# Create a new plot

figure = pyplot.figure()

axes = figure.gca(projection='3d')

# Load the STL files and add the vectors to the plot

mesh = mesh.Mesh.from_file(filename)

axes.add_collection3d(mplot3d.art3d.Poly3DCollection(mesh.vectors, color='lightgrey'))

#axes.plot_surface(mesh.x,mesh.y,mesh.z)

# Auto scale to the mesh size

scale = mesh.points.flatten()

axes.auto_scale_xyz(scale, scale, scale)

#turn off grid and axis from display

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值