Skip to content
Snippets Groups Projects
Verified Commit e81522eb authored by Tamas Gal's avatar Tamas Gal :speech_balloon:
Browse files

Improve error reporting on Direction ctor

parent f43fa441
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,13 @@ struct Direction{T<:AbstractFloat} <: FieldVector{3, T}
x::T
y::T
z::T
function Direction(x, y, z)
T = promote_type(typeof(x), typeof(y), typeof(z))
if !(T <: AbstractFloat)
throw(ArgumentError("All elements must be convertible to an AbstractFloat"))
end
new{T}(x, y, z)
end
end
Direction(ϕ, θ) = Direction(cos(ϕ)*sin(θ), sin(ϕ)*sin(θ), cos(θ))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment