You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes my code crashes because of a missing method of Rotations. perpendicular_vector while every other method in in Rotations.jl happily takes my custom StaticArrays.FieldVectors.
Here is what I mean, given some simple subtyping as recommended in the StaticArray.jl docs, we define Dir which works fine and is taken as FieldVector{3, Float64} and indices of SOneTo(3), so all fine:
julia>struct Dir <:FieldVector{3, Float64}
x::Float64
y::Float64
z::Float64end
julia> d =Dir(1, 0, 0)
3-element Dir with indices SOneTo(3):1.00.00.0
julia> R =rand(RotMatrix{3})
3×3 RotMatrix3{Float64} with indices SOneTo(3)×SOneTo(3):-0.94490.324235-0.0451206-0.254104-0.6395550.7255350.2063870.6970230.686705
julia> R * d
3-element Dir with indices SOneTo(3):-0.9448998601049303-0.25410385614891630.2063867356782747
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 of SVector{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 of SVector{3} but apparently it's not:
julia> FieldVector{3, Float64} <:SVector{3}false
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 get SVector{3} back, which introduces type instabilities since there are other methods in my code which expect Dir.
Calling the "private" method at least works:
julia> Rotations.perpendicular_vector(SVector{3}(d))
3-element SVector{3, Float64} with indices SOneTo(3):
-0.0
1.0
0.0
The text was updated successfully, but these errors were encountered:
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:
The text was updated successfully, but these errors were encountered: