Optics in FreeCAD

Show off your FreeCAD projects here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Optics in FreeCAD

Post by DeepSOIC »

Hi
I want to share some tricks (building blocks) for optics design. With the ellipse support that is coming, FreeCAD looks like a promising tool for simple optics design.
I have only two right now, but maybe more will come later
Attachments
Snell's law constraint screenshot. set the distances according to refraction indices of media.
Snell's law constraint screenshot. set the distances according to refraction indices of media.
Snells law.FCStd.png (15.46 KiB) Viewed 27156 times
Snells law.FCStd
Snell's law constraint. Set the distances according to refraction indices of media.
(2.94 KiB) Downloaded 381 times
demonstration of aberration when focusing parallel beam using spherical reflector.
demonstration of aberration when focusing parallel beam using spherical reflector.
spherical_refl.png (20.59 KiB) Viewed 27156 times
spherical_refl.FCStd
demonstration of aberration when focusing parallel beam using spherical reflector.
(3.1 KiB) Downloaded 372 times
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Optics in FreeCAD

Post by DeepSOIC »

Here's another one, a bit more interesting: simulation of a thick lens.
This lens was drawn by accident and wasn't actually engineered. It is here just to demonstrate that one can simulate a ray passing through it.
Attachments
simulation of a thick lens (screenshot)
simulation of a thick lens (screenshot)
thick_lens_simulation.FCStd.png (37.75 KiB) Viewed 27142 times
thick_lens_simulation.FCStd
simulation of a thick lens
(3.83 KiB) Downloaded 346 times
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Optics in FreeCAD

Post by DeepSOIC »

I have written a built-in Snell's law constraint for the sketcher, and playing with refraction has just become very easy.
ellipsoid-spherical lens at an angle.png
ellipsoid-spherical lens at an angle.png (175.61 KiB) Viewed 26043 times
This lens perfectly focuses a parallel beam of light into a point when it's along optical axis, but sucks at focusing the beam when it is at an angle. Does this explain why human eye has poor peripheral vision :roll: ?

To use the model, FreeCAD with the constraint is needed. You'll have to compile it from my branch, or use my Windows build (and possibly get my viruses ;) ). Check out Optical constraints development forum thread for the links.

If anyone wants to see this in master, please let me know.
Attachments
ellipsoid-spherical lens at an angle.FCStd
(6.49 KiB) Downloaded 363 times
Last edited by DeepSOIC on Tue Mar 03, 2015 11:50 pm, edited 1 time in total.
Reason: Uploaded a repaired FCStd. The original was created in early development version and didn't work in current master.
cox
Posts: 971
Joined: Wed Nov 26, 2014 11:37 pm

Re: Optics in FreeCAD

Post by cox »

I find your work fasinating and wold definitely like to see it in master.

Thank you for sharing

Keep up the good work.
Need help? Feel free to ask, but please read the guidelines first
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Optics in FreeCAD

Post by DeepSOIC »

Thanks cox!
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Optics in FreeCAD

Post by DeepSOIC »

My first ever attempt at ray-tracing. I gave a try to OCC's super new CAD Rays.

I mocked up a scene, with a lens I thought I designed to focus perfectly...
lens scene cad.png
lens scene cad.png (30.69 KiB) Viewed 23644 times
And I tried to render it, in hope to see the image of objects in front of the lens. But all I got was lots of stray light, and no actual image. Then I removed the objects, and placed a light source. At first, I got something strange and very slowly, but I realized I forgot to switch off the sun :mrgreen: , and after doing that...
lens scene.png
lens scene.png (642.63 KiB) Viewed 23644 times
To my disappointment, the result is still very noisy after a few minutes of waiting. :( But it definitely shows something useful. It demonstrates that my lens is very far from perfect. All that halo around the image...

So I went back to FreeCAD, and checked the design. Sure enough...
lens scene lens design.png
lens scene lens design.png (414.16 KiB) Viewed 23644 times
It's definitely cool to see stuff like this! But I'm not happy with the UI of CADRays. It's strange. Moving around is hard. It often becomes very laggy, so I have to switch over to opengl rendering. It doesn't like touchscreen input, and even with pen, I often find out CADRays decided I want to drag the wrong numberbox, or reset my hue value of color, or not accept light source power below 1.0...

I want gesture navigation style from FreeCAD to be in there! I still have not figured out how to pan! (apart from AWSD)
Attachments
lens-scene.FCStd
(25.97 KiB) Downloaded 276 times
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Optics in FreeCAD

Post by DeepSOIC »

Now we are talking. Rectified my lens design, focuses perfectly!
correct lens.png
correct lens.png (304.83 KiB) Viewed 23626 times
User avatar
kkremitzki
Veteran
Posts: 2511
Joined: Thu Mar 03, 2016 9:52 pm
Location: Illinois

Re: Optics in FreeCAD

Post by kkremitzki »

Now that's pretty dang cool! 8-)
Like my FreeCAD work? I'd appreciate any level of support via Patreon, Liberapay, or PayPal! Read more about what I do at my blog.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Optics in FreeCAD

Post by DeepSOIC »

Got an image of some stuff through the lens!
lens-scene 2 render.png
lens-scene 2 render.png (261.71 KiB) Viewed 23610 times
On AMD Radeon 7700 and with regular mouse, CADRays is behaving much much better, and makes a nice rendering faster.
ian.rees
Posts: 696
Joined: Sun Jun 15, 2014 3:28 am
Contact:

Re: Optics in FreeCAD

Post by ian.rees »

Bonus points for hooking this up with FEM and melting something with focused light ;). -Ian-
Post Reply