Closed tamasgal closed 11 months ago
Thank you for creating the issue! Here's a MWE:
julia> using Rotations, StaticArrays
julia> u = MVector(1,0,0)
3-element MVector{3, Int64} with indices SOneTo(3):
1
0
0
julia> v = MVector(-1,0,0)
3-element MVector{3, Int64} with indices SOneTo(3):
-1
0
0
julia> rotation_between(u,v)
ERROR: MethodError: no method matching perpendicular_vector(::MVector{3, Int64})
Closest candidates are:
perpendicular_vector(::SVector{3})
@ Rotations ~/.julia/dev/Rotations/src/util.jl:8
Stacktrace:
[1] rotation_between(u::MVector{3, Int64}, v::MVector{3, Int64})
@ Rotations ~/.julia/dev/Rotations/src/rotation_between.jl:23
[2] top-level scope
@ REPL[4]:1
Awesome, many thanks!
Sometimes my code crashes because of a missing method of
Rotations. perpendicular_vector
while every other method in inRotations.jl
happily takes my customStaticArrays.FieldVectors
.Here is what I mean, given some simple subtyping as recommended in the
StaticArray.jl
docs, we defineDir
which works fine and is taken asFieldVector{3, Float64}
and indices ofSOneTo(3)
, so all fine:Now the problem: in some rotations, the
perpendicular_vector
is called (I have not traced down when this happens but it does not happen that much in my code, so it's something which is triggered by specific constellations of the vectors) and that method only accepts subtypes ofSVector{3}
:Can we widen the input type domain or is there a specific reason why
SVector{3}
has been chosen?Btw. I aways assumed that
FieldVector{3, Float64}
is a subtype ofSVector{3}
but apparently it's not:Edit: btw. the current workaround is wrapping the custom struct into
SVector{3}
. The problem is that I need to do this at the beginning of the chain (when calling the rotation functions) and then I also getSVector{3}
back, which introduces type instabilities since there are other methods in my code which expectDir
.Calling the "private" method at least works: