"""
    cart2radial(x, y, args...)

Compute the radial coordinate from an `n`-dimensional Cartesian.

# Examples
```julia-repl
julia> Pda.cart2radial(3,4)
5.0
julia> Pda.cart2radial(1.0, 2.0, 2.0)
3.0
```
"""
@inline function cart2radial(x, y, args...)
	r2 = x^2 + y^2
	for arg in args
		r2 += arg^2
	end
	return sqrt(r2)
end

"""
	cart2radial(x::SVector)
"""
@inline function cart2radial(x::SVector{N,T}) where{N,T <: Real}
	return cart2radial(x...)
end

"""
    body2lab(X::SVector{2,T}, xc::SVector{2,T}, theta::Real)
Convert the coordinates of a point defined in the body frame `X` to
that in the lab frame.
xc: position of the origin of the body frame
theta: orientation of the body frame x axix relative to that of the lab

# Examples
```julia-repl
julia> body2lab(SVector{2,Float64}(1,0), SVector{2,Float64}(0,0), pi/4)
2-element SVector{2, Float64} with indices SOneTo(2):
 0.7071067811865476
 0.7071067811865475
```
"""
function body2lab(X::SVector{2,T},
    xc::SVector{2,T},
    theta::Real) where T
    x1 = xc[1] + X[1] * cos(theta) - X[2] * sin(theta)
    x2 = xc[2] + X[2] * cos(theta) + X[1] * sin(theta)
    return SVector{2,T}(x1, x2)
end
