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

Fix typos in comments and docstrings #401

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion docs/src/basic_types.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Basic Types

The following are basic geometric types and utilities, such as vectors and transforms, that are used all acoross the package. Using these types requires, in addition to the `using OpticSim` statement to also use the OpticSim.Geoemtry module like:
The following are basic geometric types and utilities, such as vectors and transforms, that are used all acoross the package. Using these types requires, in addition to the `using OpticSim` statement to also use the OpticSim.Geometry module like:

```@example
using OpticSim, OpticSim.Geometry
Expand Down
2 changes: 1 addition & 1 deletion samples/notebooks/BasicCSG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ begin
csg1_surf2 = leaf(csg1_surf1, OpticSim.translation(-0.5, -0.5, 0.0))
csg1_surf3 = leaf(csg1_surf1, Transform(0.0, Float64(π), 0.0, 0.5, -0.5, 0.0))

# transformed cilinder
# transformed cylinder
csg1_surf4_1 = leaf(Cylinder(0.3, 1.0), OpticSim.translation(0.0, 0.0, 0.0))
csg1_surf4 = leaf(csg1_surf4_1, OpticSim.rotation(deg2rad(cyl_rot_x), deg2rad(cyl_rot_y), deg2rad(cyl_rot_z)))

Expand Down
2 changes: 1 addition & 1 deletion samples/notebooks/EmittersIntro.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ The OpticSim package comes with various implementations of each of these basic e
* **Point** - a single point
* **RectUniform** - a uniformly sampled rectangle with user defined number of samples
* **RectGrid** - a rectangle sampled in a grid fashion
* **Hexapolar** - a circle (or an ellipse) sampled in an hexapolar fasion (rings)
* **Hexapolar** - a circle (or an ellipse) sampled in an hexapolar fashion (rings)
- Rays Directions Distribution - the interface **length** returns the number of samples, and **generate** returns the n'th sample.
* **Constant**
* **RectGrid**
Expand Down
2 changes: 1 addition & 1 deletion src/Data/HumanEye.jl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export 𝐃sd
eyeradius() = 12mm
export eyeradius

"""Posterior focal length, i.e., optical distance from entrance pupil to the retina. Focal length will change depending on accomodation. This value is for focus at ∞. When the eye is focused at 25cm focal length will be ≈ 22mm. Because the index of refraction of the vitreous humor is approximately 1.33 the physical distance from the entrance pupil to the retina will be 24mm/1.33 = 18mm."""
"""Posterior focal length, i.e., optical distance from entrance pupil to the retina. Focal length will change depending on accommodation. This value is for focus at ∞. When the eye is focused at 25cm focal length will be ≈ 22mm. Because the index of refraction of the vitreous humor is approximately 1.33 the physical distance from the entrance pupil to the retina will be 24mm/1.33 = 18mm."""
eyefocallength() = 24mm
export eyefocallength

Expand Down
2 changes: 1 addition & 1 deletion src/Examples/repeating_structure_examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function drawhexrectcolors()
Vis.drawcells(Repeat.HexBasis1(),30,cells)
end

""" Create a LatticeCluser with three elements at (0,0),(-1,0),(-1,1) coordinates in the HexBasis1 lattice"""
""" Create a LatticeCluster with three elements at (0,0),(-1,0),(-1,1) coordinates in the HexBasis1 lattice"""
function hex3cluster()
clusterelts = SVector((0,0),(-1,0),(-1,1))
eltlattice = HexBasis1()
Expand Down
2 changes: 1 addition & 1 deletion src/Geometry/AnalyticIntersection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ end
function eigenresults(rline::AbstractRay{T,N}, curve::Array{T,2}) where {T<:Real,N} # force rline and curve to use same number type to avoid expensive runtime conversion.
dim = curvedimension(curve)
orderofcurve = curveorder(curve)
movinglineorder = max(orderofcurve, Int64(ceil(orderofcurve * 2 / dim - 1))) # Hve two constraints for movingline order. Must be big enough to result in a nullspace >= orderofcurve for the first step of computing the moving lines. Also need need at least as many eigenvalues as possible intersections of the line with the curve. Eigenmatrix is square of size qgxqg so need this matrix to be at least of size qx by qx. Take the greater of the the two constraint values.
movinglineorder = max(orderofcurve, Int64(ceil(orderofcurve * 2 / dim - 1))) # Have two constraints for movingline order. Must be big enough to result in a nullspace >= orderofcurve for the first step of computing the moving lines. Also need need at least as many eigenvalues as possible intersections of the line with the curve. Eigenmatrix is square of size qgxqg so need this matrix to be at least of size qx by qx. Take the greater of the the two constraint values.

cmat = orthogonalitymatrix(curve, movinglineorder)

Expand Down
6 changes: 3 additions & 3 deletions src/Geometry/CSG/CSG.jl
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ end
Calculates the intersection of `r` with CSG object, `obj`.

Returns an [`EmptyInterval`](@ref) if there is no intersection, an [`Interval`](@ref) if there is one or two
interesections and a [`DisjointUnion`](@ref) if there are more than two intersections.
intersections and a [`DisjointUnion`](@ref) if there are more than two intersections.

The ray is intersected with the [`LeafNode`](@ref)s that make up the CSG object and the resulting `Interval`s and
`DisjointUnion`s are composed with the same boolean operations to give a final result.
Expand Down Expand Up @@ -395,7 +395,7 @@ end

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

# currrently we assume that no triangles span 2 sides of a shape, i.e. any triangle only crosses one shape boundary and
# currently we assume that no triangles span 2 sides of a shape, i.e. any triangle only crosses one shape boundary and
# so splitting is trivial
function uniontri!(
csg::CSGTree{T}, tri::Triangle{T}, triangles::Vector{Triangle{T}}, thisforcoplanar::Bool = false
Expand Down Expand Up @@ -576,7 +576,7 @@ function splittri2out!(
end
end

# visualization functions from CSG objects, most actualy work happens in the above functions
# visualization functions from CSG objects, most actually work happens in the above functions
function makemeshi(a::UnionNode{T}, subdivisions::Int = 30)::Vector{Triangle{T}} where {T<:Real}
# do the two children in parallel
th1 = Threads.@spawn makemesh(a.leftchild, subdivisions)
Expand Down
2 changes: 1 addition & 1 deletion src/Geometry/CSG/Interval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ difference(a::DisjointUnion, b::DisjointUnion) = intervalintersection(a, interva
Apply a Transform to an Interval object
"""
function Base.:*(transformation::Transform{T}, a::Interval{T}) where {T<:Real}
# looks ridiculous but necessary to dissambiguate the elements of the interval
# looks ridiculous but necessary to disambiguate the elements of the interval
u = upper(a)
l = lower(a)
if l isa RayOrigin{T}
Expand Down
2 changes: 1 addition & 1 deletion src/Geometry/Primitives/AsphericSurface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ end
function normal(z::AsphericSurface{T,3}, ρ::T, ϕ::T)::SVector{3,T} where {T<:Real}
du, dv = partials(z, ρ, ϕ)
if ρ == zero(T) && norm(dv) == zero(T)
# in cases where there is no δϕ at ρ = 0 (i.e. anything which is rotationally symetric)
# in cases where there is no δϕ at ρ = 0 (i.e. anything which is rotationally symmetric)
# then we get some big problems, hardcoding this case solves the problems
return SVector{3,T}(0, 0, 1)
end
Expand Down
2 changes: 1 addition & 1 deletion src/Geometry/Primitives/Curves/BSpline.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ spatialdimension(::Spline{T,S,N,M}) where {T,S,N,M} = N
curveorder(::Spline{T,S,N,M}) where {T,S,N,M} = M

function point(curve::BSplineCurve{P,S,N,M}, u::T)::SVector{N,S} where {T<:Real,P,S,N,M}
# returns the raw point type of the curve - for Homogeneous curve types this will be a homogenous point
# returns the raw point type of the curve - for Homogeneous curve types this will be a homogeneous point
span = findspan(curve, u)
bases = basisfunctions(curve.knotvector, u, M)
c = zeros(MVector{N,S})
Expand Down
2 changes: 1 addition & 1 deletion src/Geometry/Primitives/Curves/Bezier.jl
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ end
# end

# "Creates a differentiable function to evaluate a surface point. Zygote has trouble with mutable arrays so this creates a function
# which unrolls all loops and converts array indexing to variables. Stopped working on this because it became so diffult to make it work."
# which unrolls all loops and converts array indexing to variables. Stopped working on this because it became so difficult to make it work."
# function pointinline(surf::BezierSurface{P,S,N,M}, u::T, v::T) where {T<:Real,P,S,N,M}
# controlpoints = surf.controlpolygon
# qi = zeros(MVector{N * (M + 1),MVector{N,S},1})
Expand Down
2 changes: 1 addition & 1 deletion src/Geometry/Primitives/NonCSG/ConvexPolygon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct ConvexPolygon{N,T<:Real} <: PlanarShape{T}
local_frame::Transform{T}
# local_points::Vector{SVector{2, T}}
local_points::SMatrix{2,N,T}
# for efficency
# for efficiency
_local_frame_inv::Transform{T} # cache the inverse matrix to avoid computing it for every intersection test
_local_lines::Vector{SVector{3, SVector{2, T}}} # defines the edge points + a third point representing the slopes in order to save some calculationsduring ray checking
_length::Int64 # cache the length of the polygon
Expand Down
2 changes: 1 addition & 1 deletion src/Geometry/Primitives/Plane.jl
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function surfaceintersection(pln::Plane{T,N}, r::AbstractRay{T,N}) where {T<:Rea
end

function BoundingBox(pln::Plane{T,3}) where {T<:Real}
# TODO! this is far from ideal, we should try and do something better for intersection with non-axis-algined planes
# TODO! this is far from ideal, we should try and do something better for intersection with non-axis-aligned planes
# valid for axis aligned planes, otherwise we have to assume an infinite bounding box
if normal(pln) === SVector{3,T}(0, 0, 1)
return BoundingBox(typemin(T), typemax(T), typemin(T), typemax(T), typemin(T), pln.pointonplane[3])
Expand Down
6 changes: 3 additions & 3 deletions src/Geometry/Primitives/Qtype.jl
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,11 @@ function dSdx(coeffs::SVector{NP1,T}, m::Int, x::T)::T where {T<:Real,NP1}
dαₙ₊₁ = zero(T)
dαₙ = zero(T)
@inbounds for n in N:-1:0
# calcualte deriv
# calculate deriv
Bmn = B(m, n)
k = (A(m, n) + Bmn * x)
Cmnp1 = C(m, n + 1)
if n < N # derivative calcualted from N-1 to 0, so ignore first iteration
if n < N # derivative calculated from N-1 to 0, so ignore first iteration
# 2 eq B.11
dαₙ = Bmn * αₙ₊₁ + k * dαₙ₊₁ - Cmnp1 * dαₙ₊₂
if n > 0
Expand Down Expand Up @@ -639,7 +639,7 @@ end
function normal(z::QTypeSurface{T,D,M,N}, ρ::T, θ::T)::SVector{3,T} where {T<:Real,D,M,N}
du, dv = partials(z, ρ, θ)
if ρ == zero(T) && norm(dv) == zero(T)
# in cases where there is no δθ at ρ = 0 (i.e. anything which is rotationally symetric)
# in cases where there is no δθ at ρ = 0 (i.e. anything which is rotationally symmetric)
# then we get some big problems, hardcoding this case solves the problems
return SVector{3,T}(0, 0, 1)
end
Expand Down
2 changes: 1 addition & 1 deletion src/Geometry/Primitives/Zernike.jl
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ end
function normal(z::ZernikeSurface{T,3,P,Q,M}, ρ::T, ϕ::T)::SVector{3,T} where {T<:Real,P,Q,M}
du, dv = partials(z, ρ, ϕ)
if ρ == zero(T) && norm(dv) == zero(T)
# in cases where there is no δϕ at ρ = 0 (i.e. anything which is rotationally symetric)
# in cases where there is no δϕ at ρ = 0 (i.e. anything which is rotationally symmetric)
# then we get some big problems, hardcoding this case solves the problems
return SVector{3,T}(0, 0, 1)
end
Expand Down
4 changes: 2 additions & 2 deletions src/Geometry/Surface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ If the origin o is on the inside of the plane then the inside interval will be (

It is the programmer's responsibility to return Interval results from surfaceintersection that maintain these properties.

The following must be impemented only if the surface is being used as a detector
The following must be implemented only if the surface is being used as a detector
```julia
uv(surface::Surface{T}, p::SVector{3,T}) -> SVector{2,T}
uvtopix(surface::Surface{T}, uv::SVector{2,T}, imsize::Tuple{Int,Int}) -> Tuple{Int,Int}
Expand Down Expand Up @@ -165,7 +165,7 @@ export samplesurface
triangulate(surf::ParametricSurface{S,N}, quads_per_row::Int, extensionu::Bool = false, extensionv::Bool = false, radialu::Bool = false, radialv::Bool = false)

Create an array of triangles representing the parametric surface where vertices are sampled on an even grid in UV space.
The surface can be extended by 1% in u and v separately, and specifying either u or v as being radial - i.e. detemining the radius on the surface e.g. rho for zernike - will result in that dimension being sampled using sqwrt so that area of triangles is uniform. The extension will also only apply to the maximum in this case.
The surface can be extended by 1% in u and v separately, and specifying either u or v as being radial - i.e. determining the radius on the surface e.g. rho for zernike - will result in that dimension being sampled using sqwrt so that area of triangles is uniform. The extension will also only apply to the maximum in this case.
"""
function triangulate(surf::ParametricSurface{T,N}, subdivisons::Int, extensionu::Bool = false, extensionv::Bool = false, radialu::Bool = false, radialv::Bool = false) where {T,N}
triangles = newintrianglepool!(T)
Expand Down
10 changes: 5 additions & 5 deletions src/Geometry/Transform.jl
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ Base.transpose(a::Transform{T}) where{T<:Real} = Transform{T}(a.matrix')
# END of functions for compatibility with base matrix API


# for compatability ith the "old" RigidBodyTransform
# for compatibility ith the "old" RigidBodyTransform
"""
identitytransform([S::Type]) -> Transform{S}

Expand All @@ -240,7 +240,7 @@ end
"""
Transform(colx::Vec3{T}, coly::Vec3{T},colz::Vec3{T}, colw::Vec3{T}, ::Type{T} = Float64) where {T<:Real}

Costruct a transform from the input columns.
Construct a transform from the input columns.
"""
function Transform(colx::Vec3{T}, coly::Vec3{T}, colz::Vec3{T}, colw::Vec3{T} = zero(Vec3{T})) where {T<:Real}
return Transform{T}(vcat(hcat(colx,coly,colz,colw),SMatrix{1,4,T}(zero(T),zero(T),zero(T),one(T)) ))
Expand All @@ -250,7 +250,7 @@ end
"""
Transform(colx::Vec3{T}, coly::Vec3{T},colz::Vec3{T}, colw::Vec3{T}, ::Type{T} = Float64) where {T<:Real}

Costruct a transform from the input columns.
Construct a transform from the input columns.
"""
function Transform(colx::Vec4{T}, coly::Vec4{T}, colz::Vec4{T}, colw::Vec4{T}) where {T<:Real}
return Transform{T}(hcat(colx,coly,colz,colw))
Expand All @@ -259,7 +259,7 @@ end
"""
Transform(origin, forward) -> Transform{S}

Returns the [`Transform`](@ref) of type `S` (default `Float64`) representing the local frame with origin and forward direction. the other 2 axes are computed automaticlly.
Returns the [`Transform`](@ref) of type `S` (default `Float64`) representing the local frame with origin and forward direction. the other 2 axes are computed automatically.
"""
function Transform(origin::Vec3{T}, forward::Vec3{T} = unitZ3()) where {T<:Real}
forward = normalize(forward)
Expand Down Expand Up @@ -515,7 +515,7 @@ export world2local
"""
decomposeRTS(tr::Transform{T}) where {T<:Real}

return a touple containing the rotation matrix, the translation vector and the scale vecto represnting the transform.
return a tuple containing the rotation matrix, the translation vector and the scale vecto represnting the transform.
"""
function decomposeRTS(tr::Transform{T}) where {T<:Real}
t = Vec3(tr[1,4], tr[2,4], tr[3,4])
Expand Down
8 changes: 4 additions & 4 deletions src/GlassCat/utilities.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Transmission values are linearly interpolated from the adjacent values in the da

Absorption is defined as ``\\frac{-\\log(t)}{\\tau}`` where ``t`` is the transmission value and ``\\tau`` is the thickness, both of which are provided in the data table.

If unitless, arguments are interpretted as μm, °C and Atm respectively.
If unitless, arguments are interpreted as μm, °C and Atm respectively.

# Examples
```julia-repl
Expand Down Expand Up @@ -87,7 +87,7 @@ end
Compute the refractive index of `glass` at `wavelength`, optionally at specified `temperature` and `pressure`.
Result is relative to the refractive index of air at given temperature and pressure.

If unitless, arguments are interpretted as μm, °C and Atm respectively.
If unitless, arguments are interpreted as μm, °C and Atm respectively.

**This is defined to always equal 1.0 for Air at any temperature and pressure**, use [`absairindex`](@ref) for the absolute refractive index of air at a given temperature and pressure.

Expand All @@ -109,7 +109,7 @@ function index(glass::Glass, wavelength::Length; temperature::Temperature = TEMP
end

function index(glass::Glass, λ::T; temperature::T = T(TEMP_REF), pressure::T = T(PRESSURE_REF))::T where {T<:Real}
# all calculations for the material must be done at the refernce temperature
# all calculations for the material must be done at the reference temperature
reference_temp = T(glass.temp)

# to work out the wavelength at the reference temperature we need the RIs of air at system temp and at reference temp
Expand Down Expand Up @@ -215,7 +215,7 @@ end
"""
absairindex(wavelength; temperature=20°C, pressure=1Atm)

Compute the absolute refractive index of air at `wavelength`, optionally at specified `temperature` and `pressure`. If unitless, arguments are interpretted as μm, °C and Atm respectively.
Compute the absolute refractive index of air at `wavelength`, optionally at specified `temperature` and `pressure`. If unitless, arguments are interpreted as μm, °C and Atm respectively.

# Examples
```julia-repl
Expand Down
12 changes: 6 additions & 6 deletions src/NotebooksUtils/NotebooksUtils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mutable struct Defs
authors::String # authors
desc::String # description of the notebook
width::Int64
html::String # work area to accumulate html syntaxt in order to save cell space (ouput at the end of a single cell)
html::String # work area to accumulate html syntax in order to save cell space (output at the end of a single cell)
end
Defs() = Defs("?Authors?")
Defs(authors) = Defs(authors, "")
Expand All @@ -34,7 +34,7 @@ end
"""
function run(notebook_filename)

Launch Pluto and allow teh user to open a specific notebook.
Launch Pluto and allow the user to open a specific notebook.
"""
function run(notebook_filename)
run(; path=notebook_filename)
Expand All @@ -43,8 +43,8 @@ end
"""
function run(; port=nothing, path=nothing, sysimage_file=nothing )

Launch Pluto and allow teh user to open a specific notebook.
Also allow the usage of a sysimage file for faster loading.
Launch Pluto and allow the user to open a specific notebook.
Also allow the usage of a sysimage file for faster loading.
"""
function run(; port=nothing, path=nothing, sysimage_file=nothing, auto_detect_sysimage = false )

Expand Down Expand Up @@ -115,7 +115,7 @@ end

Launch Pluto and allow the user to open a specific sample notebook. If a notebook of the same name exists in the current working folder,
it will be opened in Pluto, otherwise, the original sample notebook will be copied to the current folder and be used.
This beheviour will prevent users from updating the original sample notebook.
This behaviour will prevent users from updating the original sample notebook.
"""
function run_sample(sample_name::String, edit_original::Bool = false)
folder, basename = splitdir(sample_name)
Expand Down Expand Up @@ -263,7 +263,7 @@ end
"""
function SetDocsBackend(be::String)

Sets the backend for documantation images.
Sets the backend for documentation images.
"""
function SetDocsBackend(be::String)
if (be == "Web")
Expand Down
2 changes: 1 addition & 1 deletion src/Optical/Emitters/AngularPower.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ end
GGaussian power distribution. Ray power is calculated by:

`power = power * exp(-(gaussianu * l^2 + gaussianv * m^2))`
where l and m are the cos_angles between the two axes respectivly.
where l and m are the cos_angles between the two axes respectively.
"""
struct Gaussian{T} <: AbstractAngularPowerDistribution{T}
gaussianu::T
Expand Down
2 changes: 1 addition & 1 deletion src/Optical/Emitters/Directions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function Emitters.generate(d::HexapolarCone{T}, n::Int64) where {T<:Real}
pind = n - (t - 6 * ringi)

ϕ = (pind / (6 * ringi)) * 2π
# elevation calculated as ring fraction multipled by max angle
# elevation calculated as ring fraction multiplied by max angle
θ = acos(clamp(one(T) + (cos(ρ * θmax) - 1), -one(T), one(T)))
return normalize(sin(θ) * (cos(ϕ) * uvec + sin(ϕ) * vvec) + cos(θ) * dir)
end
Expand Down
Loading