Currently we have a bit of code duplicacy in submodules/pathfinding/astar_continuous.jl and spaces/utilities.jl/spaces/continuous.jl
get_spatial_property does something similar with indices as to_discrete_position in pathfinding
sqr_distance in pathfinding is similar to edistance in utilities.jl
It feels like there should be something we can do to combine get_direction and edistance but I'm not sure, since get_direction cares about the sign of the result, so it can't simply take an element-wise minimum of absolute differences.
This should be solvable without breaking changes. Is there a necessity for get_spatial_index to return a CartesianIndex? It should be able to be combined with to_discrete_position, and maybe some appropriately named function for the reverse conversion (currently handled by to_continuous_position).
Similarly, edistance could just return the sqrt of sqr_distance. Perhaps sqr_distance can have the signature sqr_distance{P}(a, b), so it dispatches on periodicity. This is required since sqr_distance currently dispatches on the periodicity of AStar whereas edistance does on that of the space.
I'll try and think of something for the third point, there's probably a nifty little trick with sign that would make it work
Currently we have a bit of code duplicacy in
submodules/pathfinding/astar_continuous.jl
andspaces/utilities.jl
/spaces/continuous.jl
get_spatial_property
does something similar with indices asto_discrete_position
in pathfindingsqr_distance
in pathfinding is similar toedistance
inutilities.jl
get_direction
andedistance
but I'm not sure, sinceget_direction
cares about the sign of the result, so it can't simply take an element-wise minimum of absolute differences.This should be solvable without breaking changes. Is there a necessity for
get_spatial_index
to return aCartesianIndex
? It should be able to be combined withto_discrete_position
, and maybe some appropriately named function for the reverse conversion (currently handled byto_continuous_position
).Similarly,
edistance
could just return thesqrt
ofsqr_distance
. Perhapssqr_distance
can have the signaturesqr_distance{P}(a, b)
, so it dispatches on periodicity. This is required sincesqr_distance
currently dispatches on the periodicity ofAStar
whereasedistance
does on that of the space.I'll try and think of something for the third point, there's probably a nifty little trick with
sign
that would make it work