Skip to content

Rendering components and systems ​

Optical components are rendered by drawing their shape. Example renderings of the individual components can be found in the Mirrors, Lenses, Beamsplitters and Polarizers sections.

Components ​

The generic methods below cover every BeamletOptics.AbstractObject and every group of components such as an ObjectGroup, whose members are merged into one mesh per material, like the parts of a composite object.

BeamletOptics.render! Method
julia
render!(ax, object; material = nothing, edges = nothing, show_bounding_sphere = false, kwargs...)

Renders the object into the specified axis. Additional kwargs can be piped through to the backend.

Look

Each object is rendered with the material preset of its component class, e.g. clear glass for lenses and prisms or silver for mirrors. The parts of composite objects (e.g. the prisms and the coating of a CubeBeamsplitter) are rendered with the class of each part. Explicit kwargs like color, alpha or transparency override the preset, for all parts of the object.

  • material = nothing: one of :refractive, :reflective, :coating, :polarizer, :detector, :mechanics and :interface, overrides the component class

  • edges = nothing: draws the feature edges of the object, i.e. the sharp edges and the boundary of open surfaces, as thin dark lines. By default in the :cad look for all materials except :mechanics, in the :modern look as faint silhouettes of the glass (:refractive, :coating and :interface) only, see set_render_look

The cemented interfaces of doublet and triplet lenses are rendered as thin amber surfaces. See also studio_lighting! for the lighting of the scene.

Debugging

  • show_bounding_sphere = false: also draws the bounding sphere of the shape of the object as a magenta wireframe, for an object of several parts one sphere per part and the main sphere around all parts in orange, which the solver tests first. An object without a bounding sphere (e.g. a NonInteractableObject) gets none. With live_render! the spheres follow the object. To draw a single sphere in another color or line width, call render!(ax, sphere) (see render! of an AbstractBoundingSphere) with a sphere of BeamletOptics.bounding_sphere_of

Examples

It is recommended to use the following snippet in order to generate plots:

julia
using GLMakie, BeamletOptics

fig = Figure()
ax = LScene(fig[1,1]) # or Axis3
render!(ax, my_BMO_obj; color=:white)

Additional keyword arguments can be passed. Refer to the Makie and BeamletOptics documentation for supported options for each object.

source
BeamletOptics.render! Method
julia
render!(ax, group::AbstractObjectGroup; edges = nothing, show_bounding_sphere = false, kwargs...)

Renders all objects of the group, merged like the parts of a MultiShape object, see _render_parts!. Nested groups are merged into the meshes of the outermost group. The kwargs, e.g. material or color, and an explicit edges apply to all objects. show_bounding_sphere is consumed by the outermost group, which draws the spheres of all its objects and then the main sphere of the group in orange, see render_bounding_spheres!.

source

Materials ​

The color, opacity and shading of a component follow its material class, e.g. clear glass for lenses or metallic silver for mirrors, in the active look (:modern or :cad). The materials, feature edges and lighting are described on the Look page. Each default can be overridden with the corresponding keyword argument, e.g. render!(ax, lens; color=:orange), render!(ax, mirror; transparency=true) or render!(ax, mount; material=:mechanics).

Polarizing filters ​

BeamletOptics.render! Method
julia
render!(ax, pf::PolarizationFilter; kwargs...)

Renders the PolarizationFilter pf into the specified ax, optionally with its transmission axis.

Keyword args

  • show_transmission_axis = true: draws the transmission_axis as a line on the filter

  • axis_color = :black: color of the transmission axis line

  • axis_linewidth = 2: line width of the transmission axis line

  • show_bounding_sphere = false: draws the bounding sphere of the shape, see render! of an AbstractBoundingSphere

Remaining kwargs are passed on to the Makie mesh plot.

source
BeamletOptics.render! Method
julia
render!(ax, lipo::LinearPolarizer; kwargs...)

Renders the LinearPolarizer lipo into the specified ax, optionally with its transmission axis. The two substrate halves render like refractive optics, the filter film with the polarizer material of the render look; explicit kwargs (e.g. material, edges) apply to all parts.

Keyword args

  • show_transmission_axis = true: draws the transmission_axis as a line on the filter

  • axis_color = :black: color of the transmission axis line

  • axis_linewidth = 2: line width of the transmission axis line

  • show_bounding_sphere = false: draws the bounding spheres of the parts and the main sphere in orange, see render! of an AbstractBoundingSphere

Remaining kwargs are passed on to the Makie mesh plots of the substrate halves.

source

Systems ​

BeamletOptics.render! Method
julia
render!(ax::_RenderEnv, sys::AbstractSystem; kwargs...)

Render all objects contained in the system. The kwargs are passed on to render! of each object, e.g. show_bounding_sphere = true to draw the bounding spheres of all shapes.

source

Bounding spheres ​

A shape can state a sphere that encloses it, see BeamletOptics.bounding_sphere_of. The solver then skips the shape for every ray that misses the sphere. The spheres are drawn as magenta wireframes, either along with the components via the keyword show_bounding_sphere of render!, or on their own via render!(ax, sphere), which draws a single sphere, e.g. render!(ax, BeamletOptics.bounding_sphere_of(shape); color = :magenta). This is a debugging aid, e.g. to check that the sphere of a custom shape encloses the shape and is tight. An object that consists of several parts, e.g. a doublet lens, and an object group show one sphere per part and, in orange, the main sphere around all parts, which the solver tests first. A shape or object without a sphere (NoBoundingSphere), e.g. a NonInteractableObject, shows none.

julia
using GLMakie, BeamletOptics

lens = SphericalLens(50e-3, -50e-3, 10e-3, 25.4e-3)
mirror = RoundPlanoMirror(25.4e-3, 5e-3)
translate3d!(mirror, [0, 50e-3, 0])
system = System([lens, mirror])

fig = Figure()
ax = LScene(fig[1, 1])
render!(ax, system; show_bounding_sphere = true)

# or separately, e.g. in another color
render!(ax, system)
render!(ax, BeamletOptics.bounding_sphere_of(lens); color = :orange, linewidth = 2)

With live_render! and show_bounding_sphere = true, the spheres follow the components when they are moved, see Live rendering.

BeamletOptics.render! Method
julia
render!(ax, sphere::AbstractBoundingSphere; color = :magenta, linewidth = 1, kwargs...)

Draws the bounding sphere into ax (an LScene or Axis3), if a suitable backend is loaded, as a wireframe of three great circles (parallel to the xy-, yz- and zx-plane of the world frame) in one lines plot. A SingleBoundingSphere or MultiBoundingSphere is drawn as it is, a NoBoundingSphere gives no plot.

The solver skips a shape for every ray that misses its sphere, see BeamletOptics.bounding_sphere_of, hence the plot shows what the solver tests, e.g. to check the bounding_sphere_of method of an own shape type: the sphere must enclose the whole shape and should be tight. The sphere is computed for the current pose of the shape and does not follow a shape that is moved afterwards.

Keyword args

  • color = :magenta: color of the lines

  • linewidth = 1: line width in screen units

All other kwargs are passed on to the lines plot of Makie. Returns nothing.

julia
render!(ax, BeamletOptics.bounding_sphere_of(lens); color = :orange)

# the spheres of all objects, one per part and the main sphere of each object of several parts
render!(ax, system; show_bounding_sphere = true)

If no suitable backend is loaded, a MissingBackendError will be thrown.

source

Shapes (advanced) ​

The following methods render the shapes that components are built from. They are mainly of interest when writing custom components, see the Signed Distance Functions (SDFs) and Meshes pages of the API documentation. A BeamletOptics.UnionSDF or BeamletOptics.DifferenceSDF is rendered as one mesh, which is merged from the analytical meshes of its SDFs if all of them have one, and otherwise sampled via marching cubes. The spherical, aspherical and acylindrical lens surfaces have dedicated analytical renderers that are used automatically when a lens is rendered.

BeamletOptics.render! Method
julia
render!(ax, sdf; kwargs...)

Render the surface of the sdf into the specified axis. Shapes with an analytic tessellation (see _tessellate) are rendered as a single mesh. Other shapes are rendered based on the marching cubes algorithm, with a resolution of x_resolution, y_resolution and z_resolution samples per axis (defaults: a voxel size of 1/100 of the largest bounding box width, at most 150 samples per axis).

Additional kwargs can be passed into the mesh plot.

source
BeamletOptics.render! Method
julia
render!(ax, s::ConicSDF; color=:silver, kwargs...)

Analytical mesh renderer for a BeamletOptics.ConicSDF. Renders the concave/convex conic front reflective face in color, the cylindrical substrate side wall and the flat rear substrate base in grey into ax.

source
BeamletOptics.render! Method
julia
render!(ax, d::DifferenceSDF{T, <:ConicSDF}; color=:silver, kwargs...)

Analytical mesh renderer for a BeamletOptics.ConicSDF with an axial cylindrical bore (e.g. Cassegrain, Ritchey-Chrétien, or OAP with :collimated through-hole). Other tools are cut from the mesh of the BeamletOptics.ConicSDF, see _difference.

source
BeamletOptics.render! Method
julia
render!(axis, mesh; kwargs...)

Renders the mesh into the specified axis.

Keyword args

  • show_normals = false: shows a small line

  • show_normals_length = 0.01:

Makie kwargs

source