Skip to content

Commit

Permalink
Updating old Julia code to run on 1.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
arturgower committed Apr 15, 2019
1 parent 5e789fc commit 26a4938
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/shapes/circle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ outer_radius(c::Circle) = c.radius
volume(shape::Circle) = π * shape.radius^2

import Base.issubset
function issubset{T}(inner_circle::Circle{T}, outer_circle::Circle{T})
function issubset(inner_circle::Circle{T}, outer_circle::Circle{T}) where T
norm(origin(outer_circle) - origin(inner_circle)) <= outer_circle.radius - inner_circle.radius
end

Expand Down Expand Up @@ -62,7 +62,7 @@ function bounding_rectangle(circle::Circle)
return Rectangle(origin(circle), 2*circle.radius, 2*circle.radius)
end

function boundary_functions{T}(circle::Circle{T})
function boundary_functions(circle::Circle{T}) where T

function x(t)
check_boundary_coord_range(t)
Expand Down
2 changes: 1 addition & 1 deletion src/shapes/rectangle.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ outer_radius(r::Rectangle) = sqrt((r.width/2)^2 + (r.height/2)^2)
volume(rectangle::Rectangle) = rectangle.width*rectangle.height

import Base.issubset
function issubset{T}(inner_rect::Rectangle{T}, outer_rect::Rectangle{T})
function issubset(inner_rect::Rectangle{T}, outer_rect::Rectangle{T}) where T
all(topright(inner_rect) .<= topright(outer_rect)) &&
all(bottomleft(inner_rect) .>= bottomleft(outer_rect))
end
Expand Down
2 changes: 1 addition & 1 deletion src/shapes/sphere.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ outer_radius(sphere::Sphere) = sphere.radius
volume(shape::Sphere) = 4//3 * π * shape.radius^3

import Base.issubset
function issubset{T}(inner_sphere::Sphere{T}, outer_sphere::Sphere{T})
function issubset(inner_sphere::Sphere{T}, outer_sphere::Sphere{T}) where T
norm(origin(outer_sphere) - origin(inner_sphere)) <= outer_sphere.radius - inner_sphere.radius
end

Expand Down
4 changes: 2 additions & 2 deletions src/shapes/time_of_flight.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ name(shape::TimeOfFlight) = "Time of flight from planar source"
# Let (x,y) be a point on the curved part of the shape, then
# x - xr + sqrt((x - xr)^2 + (y - yr)^2) == T => x == T/2 + xr - (y - yr)^2/(2T)
# then the area = 2*Integrate[ T/2 + xr - (y - yr)^2/(2T), {y,yr, yr + sqrt(T^2 + 2xr*T)}]
function volume{T}(shape::TimeOfFlight{T})
function volume(shape::TimeOfFlight{T}) where T <: AbstractFloat
l_x = shape.listener_position[1]
return 2/(3*shape.time)*(shape.time^2 + 2*l_x*shape.time)^(3//2)
end
Expand All @@ -32,7 +32,7 @@ function issubset(circle::Circle, shape::TimeOfFlight)
return (origin(circle)[1] > 0) && (l_to_p[1] + norm(l_to_p) <= (shape.time - 2circle.radius))
end

function bounding_rectangle{T}(shape::TimeOfFlight{T})
function bounding_rectangle(shape::TimeOfFlight{T}) where T <: AbstractFloat
t = shape.time
l = shape.listener_position
x_max = max(t/2 + l[1], zero(T))
Expand Down
2 changes: 1 addition & 1 deletion src/shapes/time_of_flight_from_point.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function issubset(circle::Circle, shape::TimeOfFlightFromPoint)
norm(origin(circle) - shape.listener_position) < (shape.time - 2circle.radius)
end

function bounding_rectangle{T}(shape::TimeOfFlightFromPoint{T})
function bounding_rectangle(shape::TimeOfFlightFromPoint{T}) where T <: AbstractFloat
box_height = 2sqrt(shape.time^2 - shape.listener_position[1]^2)
box_width = max(shape.time + shape.listener_position[1], zero(T))
return Rectangle(SVector(zero(T), -box_height/2), SVector(box_width, box_height/2))
Expand Down

0 comments on commit 26a4938

Please sign in to comment.