diff --git a/src/GlassCat/data/sources.txt b/src/GlassCat/data/sources.txt index ce6637877..9172c88a8 100644 --- a/src/GlassCat/data/sources.txt +++ b/src/GlassCat/data/sources.txt @@ -1,7 +1,7 @@ NIKON a49714470fa875ad4fd8d11cbc0edbf1adfe877f42926d7612c1649dd9441e75 https://www.nikon.com/products/components/assets/pdf/nikon_zemax_data.zip OHARA 0c9021bf11b8d4e660012191818685ad3110d4f9490699cabdc89aae1fd26d2e https://www.oharacorp.com/xls/OHARA_201130_CATALOG.zip HOYA b02c203e5a5b7a8918cc786badf0a9db1fe2572372c1c163dc306b0a8a908854 http://www.hoya-opticalworld.com/common/agf/HOYA20210105.agf -SCHOTT 02c3212e6984a553994caf7533c6c08f284f6ebc9312dbf90e605226577577e8 https://www.schott.com/d/advanced_optics/6959f9a4-0e4f-4ef2-a302-2347468a82f5/1.32/schott-optical-glass-overview-zemax-format.zip +SCHOTT 02c3212e6984a553994caf7533c6c08f284f6ebc9312dbf90e605226577577e8 https://mss-p-009-delivery.stylelabs.cloud/api/public/content/a79c07aa61da4c05a2c0bbab93d09a7f?v=3b65e351&download=true SUMITA fad12bfb1754ee9e33f7a6ec65c784c1dd1b8e87fde1ac2e440d24e85630c758 https://www.sumita-opt.co.jp/en/wp/wp-content/themes/sumita-opt-en/download-files.php files%5B%5D=new_sumita.agf&category=data ARCHER 7df8c42fb499720165c86d77dc8065db5126541a71b4e9d6a4849e27b25dd82d https://raw.githubusercontent.com/nzhagen/zemaxglass/master/AGF_files/archer.agf ARTON d214e050f7330257c8cfcd517b1f35b64077dac62cf2729f73b3723e00a59263 https://raw.githubusercontent.com/nzhagen/zemaxglass/master/AGF_files/arton.agf diff --git a/src/RepeatingStructures/Cluster.jl b/src/RepeatingStructures/Cluster.jl index 02e020cc9..66b774055 100644 --- a/src/RepeatingStructures/Cluster.jl +++ b/src/RepeatingStructures/Cluster.jl @@ -37,6 +37,8 @@ clusterelements(a::LatticeCluster) = a.clusterelements export clusterelements elementbasis(a::LatticeCluster) = a.elementbasis clustersize(a::LatticeCluster) = length(a.clusterelements) +clusterbasis(a::LatticeCluster) = a.clusterbasis +export clusterbasis """returns the positions of every element in a cluster given the cluster indices""" function Base.getindex(A::LatticeCluster{N1,N,T,B1,B2}, indices::Vararg{Int, N}) where{N1,N,T,B1<:Basis{N,Int},B2<:Basis{N,T}} @@ -92,3 +94,5 @@ elementbasis(a::ClusterWithProperties) = elementbasis(cluster(a)) export elementbasis clustersize(a::ClusterWithProperties) = clustersize(a.cluster) export clustersize +clusterbasis(a::ClusterWithProperties) = clusterbasis(a.cluster) +export clusterbasis diff --git a/src/RepeatingStructures/HexagonalLattice.jl b/src/RepeatingStructures/HexagonalLattice.jl index 81dc40558..9dc9f6d45 100644 --- a/src/RepeatingStructures/HexagonalLattice.jl +++ b/src/RepeatingStructures/HexagonalLattice.jl @@ -19,7 +19,7 @@ struct HexBasis1{N,T} <: Basis{N,T} end export HexBasis1 -basis(::HexBasis1{2,T}) where{T} = SMatrix{2,2,T}(T(1.5),T(.5)*sqrt(T(3)),T(1.5),T(-.5)*(sqrt(T(3)))) +basismatrix(::HexBasis1{2,T}) where{T} = SMatrix{2,2,T}(T(1.5),T(.5)*sqrt(T(3)),T(1.5),T(-.5)*(sqrt(T(3)))) # SVector{2,SVector{2,T}}(hexe₁(T),hexe₂(T)) @@ -180,5 +180,5 @@ function tilevertices(::HexBasis3{2,T}) where{T} sin60, cos60) end -basis(::HexBasis3{2,T}) where{T} = SMatrix{2,2,T}(T(2*sin60),T(0),T(sin60),T(1.5)) +basismatrix(::HexBasis3{2,T}) where{T} = SMatrix{2,2,T}(T(2*sin60),T(0),T(sin60),T(1.5)) diff --git a/src/RepeatingStructures/Lattice.jl b/src/RepeatingStructures/Lattice.jl index b4f914916..6f0735559 100644 --- a/src/RepeatingStructures/Lattice.jl +++ b/src/RepeatingStructures/Lattice.jl @@ -41,7 +41,7 @@ abstract type Basis{N,T<:Real} end export Basis function Base.getindex(A::B1, indices::Vararg{Int, N}) where{N,T,B1<:Basis{N,T}} - return basis(A)*SVector{N,Int}(indices) + return basismatrix(A)*SVector{N,Int}(indices) end # temp::SVector{N,T} = (basis(A)*SVector{N,Int}(indices))::SVector{N,T} @@ -77,7 +77,7 @@ struct LatticeBasis{N,T<:Real} <: Basis{N,T} end export LatticeBasis -function basis(a::LatticeBasis{N,T})::SMatrix{N,N,T,N*N} where{N,T} +function basismatrix(a::LatticeBasis{N,T})::SMatrix{N,N,T,N*N} where{N,T} return a.basisvectors end diff --git a/src/RepeatingStructures/RectangularLattice.jl b/src/RepeatingStructures/RectangularLattice.jl index 3660f8c31..1d47b5f30 100644 --- a/src/RepeatingStructures/RectangularLattice.jl +++ b/src/RepeatingStructures/RectangularLattice.jl @@ -8,7 +8,7 @@ struct RectangularBasis{N,T} <: Basis{N,T} end export RectangularBasis -basis(::RectangularBasis{2,T}) where{T} = SMatrix{2,2,T}(T(1),T(0),T(0),T(1)) +basismatrix(::RectangularBasis{2,T}) where{T} = SMatrix{2,2,T}(T(1),T(0),T(0),T(1)) # SVector{2,SVector{2,T}}(hexe₁(T),hexe₂(T)) diff --git a/src/RepeatingStructures/Repeat.jl b/src/RepeatingStructures/Repeat.jl index 63493e22b..cb6040ad7 100644 --- a/src/RepeatingStructures/Repeat.jl +++ b/src/RepeatingStructures/Repeat.jl @@ -4,7 +4,7 @@ module Repeat -export basis +export basismatrix using Base: offset_if_vec using StaticArrays:SVector,MVector,SMatrix,MMatrix diff --git a/test/runtests.jl b/test/runtests.jl index 08308b145..e5340b049 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -10,6 +10,7 @@ using Suppressor using Random using Unitful using Plots +using DataFrames using OpticSim # Geometry Module @@ -94,6 +95,7 @@ end include("Benchmarks/Benchmarks.jl") alltestsets = [ + "Repeat", "ParaxialAnalysis", "Paraxial", "JuliaLang", @@ -109,7 +111,7 @@ alltestsets = [ "Visualization", "Allocations", "GlassCat", - "Transform", + "Transform" ] runtestsets = ALL_TESTS ? alltestsets : intersect(alltestsets, ARGS) diff --git a/test/testsets/Repeat.jl b/test/testsets/Repeat.jl new file mode 100644 index 000000000..9777abb12 --- /dev/null +++ b/test/testsets/Repeat.jl @@ -0,0 +1,18 @@ +# MIT license +# Copyright (c) Microsoft Corporation. All rights reserved. +# See LICENSE in the project root for full license information. + +@testset "Repeat" begin + function hex3RGB() + clusterelements = SVector((0,0),(-1,0),(-1,1)) + colors = [colorant"red",colorant"green",colorant"blue"] + names = ["R","G","B"] + eltlattice = Repeat.HexBasis1() + clusterbasis = Repeat.LatticeBasis(( -1,2),(2,-1)) + lattice = Repeat.LatticeCluster(clusterbasis,eltlattice,clusterelements) + properties = DataFrame(Color = colors, Name = names) + return Repeat.ClusterWithProperties(lattice,properties) + end + + @test [-1 2;2 -1] == Repeat.basismatrix(Repeat.clusterbasis(hex3RGB())) +end \ No newline at end of file