Skip to content

Commit

Permalink
InterpolatableArray is no longer necessary!
Browse files Browse the repository at this point in the history
  • Loading branch information
rdeits committed Feb 28, 2018
1 parent d675639 commit c61c146
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/animate.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,3 @@
"""
Interpolations.jl requires that one(::Type{T}) be defined for any data
type we want to interpolate. Rather than defining one(::Type{Vector}) here,
which might have unforeseen consequences in other packages, we'll create
a very simple wrapper type that just knows one() and *
"""
struct InterpolatableArray{A <: AbstractArray}
data::A
end

Base.one(::Type{InterpolatableArray{A}}) where {A} = 1
Base.:*(n::Number, a::InterpolatableArray) = n * a.data

"""
animate(vis::MechanismVisualizer,
times::Vector{Float64},
Expand All @@ -28,8 +15,7 @@ function animate(vis::MechanismVisualizer,
@assert 0 < realtimerate < Inf

state = vis.state
interp_values = [InterpolatableArray(c) for c in configurations]
interpolated_configurations = interpolate((times,), interp_values, Gridded(Linear()))
interpolated_configurations = interpolate((times,), configurations, Gridded(Linear()))
t0, tf = first(times), last(times)
framenum = 0
walltime0 = time()
Expand All @@ -45,5 +31,5 @@ function animate(vis::MechanismVisualizer,
end

animate(mechanism::Mechanism, times::Vector{Float64},
configurations::Vector{Vector{Float64}}) =
animate(Visualizer(mechanism), mechanism, times, configurations)
configurations::Vector{Vector{Float64}}; kw...) =
animate(MechanismVisualizer(mechanism), times, configurations; kw...)

0 comments on commit c61c146

Please sign in to comment.