Add ConcaveDiffractionGrating object and rotation with +/- keys #202
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello everyone,
Please be gentle, this can be considered my first contribution to any OpenSource project, and I'm not a (good, in any case) programmer, too.
I'm working on a project that makes use of a monochromator which is based around a so called "holographic aberration-corrected grating". These are concave gratings em"blazed" on mirrors, which usually are, due to easier manufacturing, indeed circular and not parabolic. This refocuses the diffractions of the "selected" wavelength to the exit slit. (Aaand creates aberrations which are countered by specifically modifying the grating, but that's a different story)
I was therefore on the lookout for a good 2D raytracing software/framework and stumbled upon ray-optics more or less by accident - it was not the first thing I found, and I was already getting frustrated. The more happy I was to have finally found such a promising base for simulating my setup.
To get to the point:
I created a new sceneObj called "ConcaveDiffractionGrating" (CDG) to the codebase. I modified some other lines of code in the necessary files to get it to work, although things like description and .svg files should be considered not implemented.
I created the CDG by mostly copying the source code of "ArcMirror" and then adding the bits of the planar "DiffractionGrating" to make it behave as I wanted. It can therefore be seen like a merge of these two sceneObjs.
I struggled (far too long) with getting the mirroring and diffracting the way it's supposed to be - it's functional, though, as is.
It is a bit hacky in some parts. (See line 372 and 390 of ConcaveDiffractionGrating.js, where a recalculation of the diffraction angle is done, because somehow the intensity calculation requires the angle to be calculated differently than before to work properly)
Additionally, since these kinds of monochromators do their wavelength-selection by rotating the grating around its middle point, I added some key-press functionality to "app.js" - namely for the +/- keys. They call the function "rotate" of the selected sceneObj. I've implemented this function for my CDG-object, but none of the other objects. See the code for "ConcaveDiffractionGrating"
--> This causes crashes of the app because the function "rotate" is not defined for all objects yet. I consider it a useful function though which should maybe be implemented for all objects. I believe someone more experienced with JS and it's classes / hierarchy etc. should implement this.
Have a look. If this is something that will eventually be accepted by the community, I'm happy to do the necessary changes or updates to the code myself to make it fully functional. (Description, svg files, tests etc) I might need some help with that, on the other hand.
I hope this is according to the contributions guidelines :)
Cheers, birdy