From f6c2db7e5cf94d1255c6ae6f5956e437b4222426 Mon Sep 17 00:00:00 2001 From: Stephan Hilb <stephan@ecshi.net> Date: Sun, 21 Nov 2021 15:57:50 +0100 Subject: [PATCH] fix offset for ImageFunction evaluation --- src/function.jl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/function.jl b/src/function.jl index c871e33..2e001fa 100644 --- a/src/function.jl +++ b/src/function.jl @@ -255,6 +255,7 @@ function evaluate(df::Derivative, x) return SArray{Tuple{df.f.space.size..., length(x)}}(jac) end + # TODO: inherit from some abstract function type struct ImageFunction{Img} mesh::Mesh @@ -266,8 +267,9 @@ ImageFunction(mesh, img) = ImageFunction(mesh, img, Ref(1)) bind!(f::ImageFunction, cell) = f.cell[] = cell +# TODO: precompute the offset from minimum mesh vertex evaluate(f::ImageFunction, xloc) = - interpolate_bilinear(f.img, elmap(f.mesh, f.cell[])(xloc)) + interpolate_bilinear(f.img, elmap(f.mesh, f.cell[])(xloc) .+ (0.5, 0.5)) struct FacetDivergence{F} -- GitLab