3D打印数学灯罩
3D-Printed Mathematical Lampshades

原始链接: https://hessammehr.github.io/blog/posts/2025-12-24-maths-to-lampshade.html

该项目详细介绍了使用软件工具和少量编程创建3D打印灯罩的过程。受类似设计的病毒式视频启发,制作者旨在基于Desmos中生成的复杂波动2D轮廓(公式为`r = cos(5θ) + 0.2cos(9θ) + 0.05cos(200θ) + 4`)构建灯罩。 最初,由于轮廓过于复杂(1047个点)导致OnShape中的“loft”操作难以实现,并导致崩溃。随后,制作者利用ChatGPT生成了一个Python脚本,将2D轮廓缩放到一个点,从而创建了所需的形状。 目前,生成的巨大STL文件正在进行3D打印。该项目还包括转换为Marimo笔记本,允许在网页浏览器中直接可视化灯罩的横截面和轮廓,而无需安装Python。

一位 Hacker News 用户 hessammehr 分享了一个项目,该项目基于数学设计制作 3D 打印灯罩(链接:hessammehr.github.io)。该项目包含 LED 灯条漫射器的 OnShape 文件,并使用 Marimo notebook 进行交互式探索。 讨论很快转向材料选择,另一位用户 Aurornis 指出 PLA 塑料可能会因 LED 灯产生的热量而软化,并建议使用 PETG 或 ASA。 hessammehr 回复说,该项目更侧重于艺术 3D 建模(使用 Blender),而不是精确的 CAD 软件,如 OpenSCAD,但他欢迎使用后者进行尝试。两位用户都强调了 Bambu 3D 打印机的可靠性——hessammehr 使用 A1 mini,而评论者拥有一台 P2S,能够处理复杂的几何形状。
相关文章

原文
Finished lampshade

I’ve been playing with translucent PLA for lighting projects at home. Earlier this year, I built a diffuser/housing for our Lidl LED strip, since the light from the exposed LEDs was too cool and jarring. The design files are on OnShape, although they might need tweaking for the exact strip and required installation area.

A few viral videos have recently popped up in my YouTube feed showing bespoke 3D-printed lampshades. These ondulating membranes struck me as a surface that would arise from sweeping 2D profile as it’s raised and rotated through space. Making one from scratch seemed like a fun challenge (not to mention a nice Christmas present!).

2D profile

I started by graphing the following equation in Desmos (link will take you to the formula).

\[ r = \cos(5\theta) + 0.2\cos(9\theta) + 0.05\cos(200\theta) + 4\]

Something like this with big gentle ondulations on top of which small jittery ridges are overlapped.

alt text

Trying (and failing) 3D with OnShape

Desmos helpfully allows export to SVG, which I then converted to DXF in Inkscape so it can be imported into OnShape. DXF files can be added to OnShape sketches directly. So far so good. Creating the loft object in OnShape proved challenging though. A loft is pretty much what I described earlier, the volume or surface created as one 2D profile is interpolated to another. In this case, the second profile is just a point placed above the initial one. Something like this:

The loft tool provide a few nice settings, specifically the initial and final angle of approach to each profile. I want the shape to rise straight from the 2D contour and form a tangent to the final point. This way the top will form a nice dome rather than a sharp spike.

This complex organic-looking profile, made up of 1047 points, doesn’t really seem to fit OnShape’s main usecase. The loft operation kept failing to process (although it looks nice) and froze a couple of times too.

alt text

At this point, I had another idea. Since the point coordinates are known, it shouldn’t be too hard to create the shape in Python. This is not something I had done before, so I asked ChatGPT for advice. It gave me a script, which I was able to modify (repo here) to create the transition to a single point at the top (essentially scaling the profile depending on height). The results is a massive 70+MB STL file, which is currently printing …

Lampshade being 3D printed

Update: I’ve converted the Jupyter notebook to marimo so it’s easier to visualise the cross section and profile of the generated lampshade. You don’t even need to install Python to run this code, it will run directly in the browser using WebAssembly (link).

联系我们 contact @ memedata.com