Skip to content

Use the center ray of BMO sources, add line and fan sources #22

Closed

Description

@StackEnjoyer

Based on StackEnjoyer/BeamletOptics.jl#116:

  1. Center ray guarantee. The first beam of every CollimatedSource and PointSource generated by a constructor is the center ray: first(BMO.beams(src)) starts at the source position along the source direction. This holds for CollimatedSource, PointSource, UniformDiscSource, UniformPointSource and the two new sources, also after set_num_rays!. The sunflower sources had no center ray before; their spiral now starts at the center.

  2. Two new exported sources, both constructors of the existing types:

    • UniformLineSource(pos, dir, width, λ = 1e-6; num_rays = 101, basis) returns a CollimatedSource: parallel rays equidistant on a line along basis.
    • UniformFanSource(pos, dir, θ, λ = 1e-6; num_rays = 101, basis) returns a PointSource: rays with equidistant angles in [-θ, θ] in the plane of dir and basis.

    Their samplings are the new public names BMO.DiscLine and BMO.ConeFan.

What does not hold

  • Sources that wrap given beams (CollimatedSource(beams, …), PointSource(beams, …), sampling BMO.NoSampling) have no center ray guarantee. BMO.min_num_rays(src) === nothing identifies them. AstigmaticBeamGroups are not covered either.
  • After the source was moved, the center ray agrees with position(src) and direction(src) only up to rounding (about 1e-16). After set_pivot3d!, position(src) is the pivot, not the emission point. Take the snap point from the beam, not from the group pose.

Tasks

  • _central_beam (src/LivePolarization.jl): return first(BMO.beams(src)) for a CollimatedSource or PointSource whose rays can be regenerated (BMO.min_num_rays(src) !== nothing). Keep the nearest-to-axis search as the fallback for wrapped beams and other beam groups. Snap, align, measure and the polarization overlay use this function.
  • _beam_text (src/LiveCardRows.jl): the docstring says the AOI is that of "the center ray of a ring source". The first ray is now the center ray of all generated sources; update the docstring. Check that the first hit in _hits is still the center ray if the center ray misses the object.
  • Ray slider (_ray_steps in src/LiveCardRows.jl): the steps 10, 20, 50, 100, … are even. For a line or fan source, an even number of rays yields the pattern of n - 1 rays plus a second ray at the center, since a pattern that is symmetric to its center ray has an odd number of rays. Use odd steps (11, 21, 51, 101, …) for sources with src.sampling isa Union{BMO.DiscLine, BMO.ConeFan}.
  • Catalog (_builtin_catalog in src/LiveCatalogEntries.jl): add "Uniform line source" (UniformLineSource, parameters width, wavelength, rays) and "Uniform fan source" (UniformFanSource, parameters half angle, wavelength, rays), with a default of 101 rays. Both need icons.
  • Plane of the rays in the catalog: the sources are constructed along +y without basis, for which BMO picks normal3d([0, 1, 0]) = [0, 0, -1], i.e. the line or fan lies in the y-z plane. Decide whether the entries pass basis = [1, 0, 0] (rays in the x-y plane of the breadboard) and whether the generated code shows it.
  • Card of a line source: it is a CollimatedSource, so properties and the source row show its width as "Diameter". Decide whether the card should say "width" for BMO.DiscLine.
  • Tests: add both sources to the list in test/TestLiveCatalogEntries.jl and add code string tests like those of UniformDiscSource. Add a test that _central_beam returns the first beam of all six generated sources and the nearest beam for a wrapped source.
  • Skill: add both sources to the list in skills/beamletopticsgui/API.md.

Check after the BMO update

  • Tests that depend on the position of the first ray of a UniformDiscSource or UniformPointSource: it moved onto the axis. All other rays of these sources are unchanged.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions