Hi, I’m trying to define several types like:
using StaticArrays
struct CartesianPoint{T <: Number} <: FieldVector{3, T}
x::T
y::T
z::T
end
struct UnitCartesianPoint{T <: Number} <: FieldVector{3, T}
x::T
y::T
z::T
end
struct PolarPoint{T <: Number} <: FieldVector{3, T}
r::T
θ::T
h::T
end
struct UnitPolarPoint{T <: Number} <: FieldVector{3, T}
r::T
θ::T
h::T
end
const AbstractPoint{T} = Union{CartesianPoint{T}, PolarPoint{T}, UnitCartesianPoint{T}, UnitPolarPoint{T}} where T
struct LOR{T <: AbstractPoint}
origin::T
direction::T
end
struct Gamma{P<:AbstractPoint, T}
p::P{T}
r::Array{T, 1}
end
I got
ERROR: LoadError: TypeError: in Type{...} expression, expected UnionAll, got TypeVar
The definition of Gamma
is trying to define a composite of Point-like type and another array with same number type. UnitCartesianPoint
and UnitPolarPoint
are just points with norm restricted to one (although I don’t know how to restrict it in struct definition).
-
Is this the proper way to describe this kind of types? Especially for
const AbstractPoint
, I don’t know if this is the correct way, it seems a little wired to me. -
How to solve the Error?