在 Python 中可以使用各种库来模拟光学追迹。其中常用的有 RayTracing、OpticalRayTracer 和 PyTracer。
下面是一个使用 RayTracing 库进行简单光学追迹的示例代码:
from raytracing import Scene, Sphere, PointLight
# 创建场景scene = Scene()
# 添加球体
sphere = Sphere(position=(0, 0, 3), radius=1, material={'color': 'white'})
scene.add_object(sphere)