USER FORUM
(you are viewing a thread; or go back to list of threads)
Using SolveSpace as a 2D angular constraint solver for an optical layout program (by Sean)
Hi there,
I've been trying to come up with a way to programmatically create optical layouts (graphics containing components such as mirrors and showing the path that laser light takes around such components). This avoids having to manually maintain such layouts in vector graphics editing programs such as Inkscape. This is particularly irritating when it comes to optics, because rotating a mirror results in the light beams having to be realigned all over the diagram.
I've written up a more detailed description over on the FreeCAD forum, if you care to take a look: https://forum.freecadweb.org/viewtopic.php?f=10&t=21712
I was hoping to use an existing constraint solver that can handle angles, because my attempts to write my own or adapt others has so far been unfruitful. The critical feature for such a solver is that it must be able to handle cyclic graphs (when one node connects to another via two different edges); this is paramount for optical layouts (interferometers - which I draw all the time - use mirrors to split light and recombine the beams having taken two different paths). I thought FreeCAD would work, but it apparently can't handle cyclic graphs.
Can anyone give me an idea of whether this would be possible with SolveSpace? My idea would be to use SolveSpace's library as the solver for my Python program.
Thanks for reading!
I've been trying to come up with a way to programmatically create optical layouts (graphics containing components such as mirrors and showing the path that laser light takes around such components). This avoids having to manually maintain such layouts in vector graphics editing programs such as Inkscape. This is particularly irritating when it comes to optics, because rotating a mirror results in the light beams having to be realigned all over the diagram.
I've written up a more detailed description over on the FreeCAD forum, if you care to take a look: https://forum.freecadweb.org/viewtopic.php?f=10&t=21712
I was hoping to use an existing constraint solver that can handle angles, because my attempts to write my own or adapt others has so far been unfruitful. The critical feature for such a solver is that it must be able to handle cyclic graphs (when one node connects to another via two different edges); this is paramount for optical layouts (interferometers - which I draw all the time - use mirrors to split light and recombine the beams having taken two different paths). I thought FreeCAD would work, but it apparently can't handle cyclic graphs.
Can anyone give me an idea of whether this would be possible with SolveSpace? My idea would be to use SolveSpace's library as the solver for my Python program.
Thanks for reading!
(no subject) (by Jonathan Westhues)
SolveSpace permits arbitrary cyclic dependencies. (In fact, the solver never explicitly builds a dependency graph; it mostly just solves the whole thing in one big Newton's method.) It's unlikely to be optimally fast, convergent, etc. for the problem that you describe, which contains structure that we don't exploit, but it should work.
(no subject) (by Sean)
Hi Jonathan, that's great! Are there any code examples using the library to solve a set of points with constraints? I can see tutorials for the GUI, but not for the library.
(no subject) (by Jonathan Westhues)
No tutorials, just the documentation and some examples. I'd suggest trying your geometry in the GUI first, then coding it once everything works.
(no subject) (by Sean)
Ok, cheers for the info - I'll look into it.
Post a reply to this comment: