Skip to content

Commit

Permalink
Merge pull request #2 from RoyWiggins/master
Browse files Browse the repository at this point in the history
Update to 1.0
  • Loading branch information
sswatson authored Mar 18, 2019
2 parents 852d677 + b5a5b7b commit a432e5c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 29 deletions.
4 changes: 2 additions & 2 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
julia 0.6
Requires
julia 1.0
Requires
38 changes: 18 additions & 20 deletions src/ConformalMaps.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
__precompile__(true)

module ConformalMaps

using Printf
# This package provides a ConfomalMap type which numerically approximates the
# conformal map from a Jordan domain specified by a list of points on the
# boundary to a disk or half-plane.
Expand All @@ -25,13 +23,13 @@ export ConformalMap,
# Conformal Map Types
#-----------------------------------------------------------------------------

immutable ConformalMap{T<:Real} # A map from the domain to the disk
struct ConformalMap{T<:Real} # A map from the domain to the disk
domain::Array{Complex{T},1} # Points tracing out the boundary
data::Array{Complex{T},1} # An array (ζ in the paper) encoding the conformal map
center::Complex{T} # The point in the domain which maps to the origin
end

immutable InverseConformalMap{T<:Real} # A map from the disk to the domain
struct InverseConformalMap{T<:Real} # A map from the disk to the domain
domain::Array{Complex{T},1}
data::Array{Complex{T},1}
center::Complex{T}
Expand Down Expand Up @@ -84,8 +82,8 @@ function ConformalMap(domain::Array{Tuple{<:Real,<:Real},1},
return ConformalMap(complexdomain,center;kwargs...)
end

function InverseConformalMap{T<:Real}(domain::Array{Complex{T},1},
center::Complex{T};kwargs...)
function InverseConformalMap(domain::Array{Complex{T},1},
center::Complex{T};kwargs...) where T<:Real
return inv(ConformalMap(domain,center;kwargs...))
end

Expand Down Expand Up @@ -162,8 +160,8 @@ end
#-----------------------------------------------------------------------------
# for conveniently splitting complex numbers and arrays of them into
# real and imaginary parts
realify{T<:Complex}(A::Array{T,1}) = hcat(real(A),imag(A))
realify{T<:AbstractFloat}(z::Complex{T}) = (real(z),imag(z))
realify(A::Array{T,1}) where {T<:Complex} = hcat(real(A),imag(A))
realify(z::Complex{T}) where {T<:AbstractFloat} = (real(z),imag(z))
realify(x::Real) = (x,0.0)
#-----------------------------------------------------------------------------

Expand All @@ -172,9 +170,9 @@ realify(x::Real) = (x,0.0)
#-----------------------------------------------------------------------------
# f and finv are the basic slit-domain conformal maps composed to
# construct the global conformal map
function f{T<:AbstractFloat}(z::Union{T,Complex{T}},
a::Union{T,Complex{T}};
tol::Float64=1e-12)
function f(z::Union{T,Complex{T}},
a::Union{T,Complex{T}};
tol::Float64=1e-12) where T<:AbstractFloat
if isnan(z)
return -im*sign(imag(a))*abs(a)^2*sqrt(1/real(a)^2+1/imag(a)^2)
elseif abs(imag(a)) < tol
Expand All @@ -184,9 +182,9 @@ function f{T<:AbstractFloat}(z::Union{T,Complex{T}},
end
end

function finv{T<:AbstractFloat}(w::Union{T,Complex{T}},
a::Union{T,Complex{T}};
tol::Float64=1e-12)
function finv(w::Union{T,Complex{T}},
a::Union{T,Complex{T}};
tol::Float64=1e-12) where T<:AbstractFloat
if abs(imag(a)) < tol
return sqrt(w^2+a^2)
elseif isnan(w)
Expand Down Expand Up @@ -366,18 +364,18 @@ function hinv(z::Union{Real,Complex},c::Complex,a::Complex;args...)
return (z->b*z/(b+z))(fzip(d,z))
end

function hcompose{T<:AbstractFloat}(A::Array{Complex{T},1},
z::Union{Real,Complex};
realline::Bool=false)
function hcompose(A::Array{Complex{T},1},
z::Union{Real,Complex};
realline::Bool=false) where T<:AbstractFloat
zpr = z
for i=1:2:length(A)
realline ? zpr = real(h(zpr,A[i],A[i+1])) : zpr = h(zpr,A[i],A[i+1])
end
return zpr
end

function hinvcompose{T<:AbstractFloat}(A::Array{Complex{T},1},
w::Union{T,Complex{T}})
function hinvcompose(A::Array{Complex{T},1},
w::Union{T,Complex{T}}) where T<:AbstractFloat
for i=length(A)-1:-2:1
w = hinv(w,A[i],A[i+1])
end
Expand Down
12 changes: 6 additions & 6 deletions src/visualization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using AsyPlots
using ConformalMaps

immutable ConformalMapVisualization
struct ConformalMapVisualization
domain::AsyPlots.Plot2D
range::AsyPlots.Plot2D
end
Expand Down Expand Up @@ -53,11 +53,11 @@ function hyperbolictiling(f::Union{Function,InverseConformalMap};

points = [[f((1-(1-innerradius)/2^(k-1))*cos+rotation) +
im*(1-(1-innerradius)/2^(k-1))*sin+rotation))
for θ=linspace(0,2π,1+rays*2^(k-1))] for k=1:rings]
for θ=range(0, stop=2π, length=1+rays*2^(k-1))] for k=1:rings]
return Plot([
(isa(f,InverseConformalMap) ? domain(f) :
[Point2D(f(0.0),linewidth=2),
Polygon2D([f(cis(θ)) for θ=linspace(0,2π,250)];linewidth=0.3)]);
Polygon2D([f(cis(θ)) for θ=range(0, stop=2π, length=250)];linewidth=0.3)]);
[Path2D([points[i][k],points[i+1][2*k-1]];
color=raycolor,linewidth=lwfunction(i))
for i=1:length(points)-1 for k=1:length(points[i])-1]
Expand Down Expand Up @@ -126,8 +126,8 @@ function makegrid(boundary::Array{AsyPlots.Vec2,1},n::Integer)
m = length(minimum(xvals):ϵ:maximum(xvals))
n = length(minimum(yvals):ϵ:maximum(yvals))
totalgrid = [(x,y) for
x = linspace(minimum(xvals),maximum(xvals),m),
y = linspace(minimum(yvals),maximum(yvals),n)]
x = range(minimum(xvals), stop=maximum(xvals), length=m),
y = range(minimum(yvals), stop=maximum(yvals), length=n)]
pointsinside = [iswellinside(AsyPlots.Vec2(totalgrid[i,j]),
boundary;epsilon=1e-3) ? 1 : 0 for i=1:m,j=1:n]
lines = Tuple{Tuple{Int64,Int64},Tuple{Int64,Int64}}[]
Expand All @@ -147,7 +147,7 @@ function makegrid(boundary::Array{AsyPlots.Vec2,1},n::Integer)
return totalgrid, pointsinside, lines
end

makegrid{T<:Complex}(boundary::Array{T,1},n::Integer) =
makegrid(boundary::Array{T,1},n::Integer) where {T<:Complex} =
makegrid(hcat(reim(boundary)...),n)

function grid(domain,totalgrid,pointsinside,lines,center)
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using ConformalMaps
using Base.Test
using Test
using Requires

vertices = [1.0 0.0;
Expand Down

0 comments on commit a432e5c

Please sign in to comment.