Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

latticeExtensions #215

Merged
merged 72 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
282818b
Extensions to existing lattic code.
BrianGun Jun 26, 2021
383fe7c
adding code for repeating structures
BrianGun Jun 27, 2021
9f088f0
rewrote lattice functions. Much simpler now.
BrianGun Jun 27, 2021
f50b3ff
generalized lattice type so it works in any dimension
BrianGun Jun 27, 2021
378a120
optimized LatticeBasis constructor by tweaking type annotation. 50x f…
BrianGun Jun 27, 2021
21d3acb
documentation changes in Lattice.jl
BrianGun Jun 28, 2021
d45191f
documentation change in Lattice.jl
BrianGun Jun 28, 2021
9c0c862
added const ring1 ring2 definitions using diagonal arrows which Julia…
BrianGun Jun 28, 2021
729965e
added code to Lattice.jl to create the 1 and 2 ring hex patterns.
BrianGun Jun 28, 2021
6a24a3b
added hex to ring1,ring2 function names
BrianGun Jun 28, 2021
ace704a
small simplifications to hexring functions in Lattice.jl
BrianGun Jun 28, 2021
b90cd61
changing lattice rings to generate both i,j indices of ring hexagons …
BrianGun Jun 29, 2021
5dc5678
changed hexring functions to generate i,j coordinate offsets rather t…
BrianGun Jun 29, 2021
b1eb4b3
comment change
BrianGun Jun 29, 2021
40e7fd9
doc change
BrianGun Jun 29, 2021
6413786
generalizing hexagonal lattice code so up down, etc. work regardless …
BrianGun Jul 1, 2021
78db9b2
new hex code simplies bases and ring calculation.
BrianGun Jul 1, 2021
600b866
moved using statements from Visualization.jl to Vis.jl because Vis.jl…
BrianGun Jul 1, 2021
5651bd6
added VisRepeatingStructures.jl
BrianGun Jul 1, 2021
e0dc745
added hexgrid visualization code. Fixed hex basis errors.
BrianGun Jul 1, 2021
1b2a74c
comment change
BrianGun Jul 2, 2021
870b486
got ring1 and ring2 hexagons working and rewrote hexpoints to work wi…
BrianGun Jul 3, 2021
50b0842
simplifying ring function to make it completely general.
BrianGun Jul 3, 2021
65cccd0
last offset in hexcycle was hexdownleft() should have been hexdownrig…
BrianGun Jul 3, 2021
3e270b7
made hexcycle const
BrianGun Jul 3, 2021
efad851
changed hexcellsinbox to return a 1D array and added color option to …
BrianGun Jul 3, 2021
cfaaf27
documentation change
BrianGun Jul 3, 2021
cb53feb
cleaned up code gave hex lattice functions more informative names, be…
BrianGun Jul 3, 2021
d001751
working on documentation for repeating structures.
BrianGun Jul 3, 2021
a8257e1
changed hexup(), etc. to take a number of steps arg. This will be use…
BrianGun Jul 3, 2021
d57cb64
more name changes and doc changes
BrianGun Jul 3, 2021
0476c2e
scaled text to be proportional to size of hex cell so it is more read…
BrianGun Jul 3, 2021
090036a
Merge branch 'main' into latticeExtensions
BrianGun Jul 3, 2021
3d672ab
added license notice
BrianGun Jul 3, 2021
e0c57f6
Merge branch 'latticeExtensions' of https://github.com/microsoft/Opti…
BrianGun Jul 3, 2021
c904e47
added license header
BrianGun Jul 6, 2021
442ce45
added examples for repeating structures. changed docs to include neig…
BrianGun Jul 6, 2021
6bfef3d
Merge branch 'main' into latticeExtensions
BrianGun Jul 6, 2021
d5e7146
added license line
BrianGun Jul 6, 2021
384f896
example code change
BrianGun Jul 7, 2021
10e8b48
modified Vis.jl file to have same import/usings as used to be in Visu…
BrianGun Jul 7, 2021
f5d4300
updated comment in Vis.jl about precompiled sysimage
BrianGun Jul 7, 2021
bc1d462
fixed examples for repeating structures.
BrianGun Jul 7, 2021
f99b21c
Update docs/make.jl
BrianGun Jul 8, 2021
76014e5
file name change, hexregion -> region(::LatticeBasis...) first crack …
BrianGun Jul 8, 2021
1e8828f
tweaking repeat documentation
BrianGun Jul 8, 2021
03813f0
added tilevertices to interface for lattice so vertices of unit tile …
BrianGun Jul 8, 2021
55c0505
Merge branch 'main' into latticeExtensions
BrianGun Jul 8, 2021
39d1949
Merge branch 'main' into latticeExtensions
BrianGun Jul 9, 2021
b3f1ad6
Merge branch 'main' into latticeExtensions
BrianGun Jul 12, 2021
a44c8e0
Merge branch 'latticeExtensions' of https://github.com/microsoft/Opti…
BrianGun Jul 12, 2021
e44fed1
removed call to Vis.save because that only works with Makie, not Luxor.
BrianGun Jul 13, 2021
46b8e04
updated project.toml to makie 0.14.2
BrianGun Jul 13, 2021
af34a01
Merge branch 'main' into latticeExtensions
BrianGun Jul 13, 2021
0107419
documentation for repeating structures module.
BrianGun Jul 13, 2021
5fdc536
repeat structure documentation improvements.
BrianGun Jul 13, 2021
a134fc1
documentation improvements for repeat
BrianGun Jul 13, 2021
4d34a03
more doc improvements for repeat
BrianGun Jul 13, 2021
cb7e22b
typo in repeat documentation
BrianGun Jul 13, 2021
370c98c
fixes to repeat documentation
BrianGun Jul 13, 2021
0bf8e96
documentation changes for repeat
BrianGun Jul 14, 2021
b310a49
added Luxor to project.toml in docs project. small changes to vis of …
BrianGun Jul 14, 2021
a44e70a
Merge branch 'main' into latticeExtensions
BrianGun Jul 14, 2021
25859c9
example illustrations for repeat didn't show up because forgot to use…
BrianGun Jul 14, 2021
7ccbfe3
type in repeat docs
BrianGun Jul 14, 2021
f167307
typo in repeat docs. Visualization doesn't return luxor drawing prope…
BrianGun Jul 15, 2021
ff1ef7a
adding VSCodeCounter directory to .gitignore
BrianGun Jul 15, 2021
3d9ff1b
added .VSCodeCounter directory to .gitignore
BrianGun Jul 15, 2021
5a7b353
added the bility to produce a repeatable drawing in different formats…
galran Jul 16, 2021
d938bff
Merge branch 'main' into latticeExtensions
BrianGun Jul 16, 2021
14a09f8
Merge branch 'main' into latticeExtensions
BrianGun Jul 16, 2021
f53b5f8
removed Luxor from the docs project and fixed the Vis.drawhexcells to…
galran Jul 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ Sumita.jl

## Julia.gitignore ##

# files generated by VSCode Counter
.VSCodeCounter/

# Files generated by invoking Julia with --code-coverage
*.jl.cov
*.jl.*.cov
Expand Down
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Luxor = "ae8d54c2-7ccd-5906-9d76-62fc9837b5bc"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
OpticSim = "24114763-4efb-45e7-af0e-cde916beb153"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Expand Down
3 changes: 2 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ makedocs(
"Geometry" => [
"Basic Types" => "basic_types.md",
"Primitives" => "primitives.md",
"CSG" => "csg.md"
"CSG" => "csg.md",
"Repeating Structures" => "repeat.md"
],
"Optical" => [
"Systems" => "systems.md",
Expand Down
63 changes: 63 additions & 0 deletions docs/src/repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Repeating Structures

The Repeat module contains functions for creating regular repeated patterns. This could be pixels in a display grid, or mirrors in an active optics telescope. Repeated patterns are defined by creating an object that inherits from the abstract type [`Basis`](@ref sources).

Subtypes supporting the Basis interface should implement these functions:

Returns the neighbors in ring n surrounding centerpoint, excluding centerpoint
```
neighbors(::Type{B},centerpoint::Tuple{T,T},neighborhoodsize::Int) where{T<:Real,B<:Basis}
```
Returns the lattice basis vectors that define the lattice
```
basis(a::S) where{S<:Basis}
```
Returns the vertices of the unit polygon for the basis that tiles the plane
```
tilevertices(a::S) where{S<:Basis}
```

A lattice is described by a set of lattice vectors eᵢ which are stored in a [`Basis`](@ref sources) object. You can create bases in any dimension. Points in the lattice are indexed by integer coordinates. These lattice coordinates can be converted to Cartesian coordinates by indexing the LatticeBasis object.
``` @example example
using OpticSim, OpticSim.Repeat
a = LatticeBasis([1.0,5.0],[0.0,1.0])
a[3,3]
```

The Lattice points are defined by a weighted sum of the basis vectors:
```
latticepoint = ∑αᵢ*eᵢ
```
where the αᵢ are integer weights.

The [`HexBasis1`](@ref sources) constructor defines a symmetric basis for hexagonal lattices
```@example
using OpticSim, OpticSim.Repeat
basis(HexBasis1())
```
The [`rectangularlattice`](@ref sources) function creates a rectangular lattice basis.

There are a few visualization functions for special 2D lattices. [`Vis.drawhexcells`](@ref sources) draws a set of hexagonal cells. Using [`Repeat.hexcellsinbox`](@ref sources) we can draw all the hexagonal cells that fit in a rectangular box:

```@example
using OpticSim
Vis.drawhexcells(50,Repeat.hexcellsinbox(2,2))
HTML(Vis.drawhexcells(50,Repeat.hexcellsinbox(2,2), format=:svg)) #hide
```

There is also a function to compute the n rings of a cell x, i.e., the cells which can be reached by taking no more than n steps along the lattice from x:

```@example
using OpticSim
Vis.drawhexcells(50,Repeat.neighbors(Repeat.HexBasis1,(0,0),2))
HTML(Vis.drawhexcells(50,Repeat.neighbors(Repeat.HexBasis1,(0,0),2), format=:svg)) #hide
```

You can also draw all the cells contained within an n ring:

```@example
using OpticSim
Vis.drawhexcells(50,Repeat.region(Repeat.HexBasis1,(0,0),2))
HTML(Vis.drawhexcells(50,Repeat.region(Repeat.HexBasis1,(0,0),2), format=:svg)) #hide
```

137 changes: 137 additions & 0 deletions luxor-drawing-163404_864.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/Examples/Examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,19 @@ using ..OpticSim.Vis
using ..OpticSim.Geometry
using ..OpticSim.Emitters
using ..OpticSim.GlassCat
using ..OpticSim.Repeat

using StaticArrays
using DataFrames: DataFrame
using Images
using Unitful
using Plots
using LinearAlgebra
import Luxor

include("docs_examples.jl")
include("other_examples.jl")
include("repeating_structure_examples.jl.jl")

end #module Examples
export Examples
23 changes: 23 additions & 0 deletions src/Examples/repeating_structure_examples.jl.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# MIT license
# Copyright (c) Microsoft Corporation. All rights reserved.
# See LICENSE in the project root for full license information.



#############################################################################

"""draw the 2 neighbors of the hex cell at coordinates (0,0)"""
drawhexneighbors() = Luxor.@svg Vis.drawhexcells(50,Repeat.neighbors(Repeat.HexBasis1,(0,0),2))
export drawneighbors

"""draw hex cell at coordinates (0,0) and the 1 and 2 neighbors"""
drawhexregion() = Luxor.@svg Vis.drawhexcells(50,Repeat.region(Repeat.HexBasis1,(0,0),2))
export drawhexregion

"""draw hex cells that fit within a rectangular box centered at coordinates (0,0). Use fill color yellow."""
drawhexrect() = Luxor.@svg Vis.drawhexcells(50,Repeat.hexcellsinbox(2,2),"yellow")
export drawhexrect

"""draw hex cells that fit within a rectangular box centered at coordinates (0,0). Use random fill colors selected for maximum distinguishability."""
drawhexrectcolors() = Luxor.@svg Vis.drawhexcells(50,Repeat.hexcellsinbox(4,4))
export drawhexrectcolors
1 change: 1 addition & 0 deletions src/OpticSim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import .GlassCat: plot_indices, index, polyfit_indices, absairindex, absorption,

include("Geometry/Geometry.jl")
include("Optical/Optical.jl")
include("RepeatingStructures/Repeat.jl")
include("Vis/Vis.jl")
include("Examples/Examples.jl")
include("Optimization/Optimization.jl")
Expand Down
Loading