Extent
You can get Extent of an array of mathical vectors or particles by calling extent functions:
julia> using PhysicalParticlesjulia> p = [Ball(PVector(-1.0u"m", 1.0u"m", 1.0u"m"), PVector(u"m/s"), PVector(u"m/s^2"), 1.0u"kg", 1), Ball(PVector(1.0u"m", -1.0u"m", -1.0u"m"), PVector(u"m/s"), PVector(u"m/s^2"), 1000.0u"g", 2)]2-element Vector{Ball{Unitful.Quantity{Float64, ๐, Unitful.FreeUnits{(m,), ๐, nothing}}, Unitful.Quantity{Float64, ๐ ๐^-1, Unitful.FreeUnits{(m, s^-1), ๐ ๐^-1, nothing}}, Unitful.Quantity{Float64, ๐ ๐^-2, Unitful.FreeUnits{(m, s^-2), ๐ ๐^-2, nothing}}, M, Int64} where M}: Ball 1: Pos = PVector(-1.0 m, 1.0 m, 1.0 m), Vel = PVector(0.0 m s^-1, 0.0 m s^-1, 0.0 m s^-1), Acc = PVector(0.0 m s^-2, 0.0 m s^-2, 0.0 m s^-2), Mass = 1.0 kg Ball 2: Pos = PVector(1.0 m, -1.0 m, -1.0 m), Vel = PVector(0.0 m s^-1, 0.0 m s^-1, 0.0 m s^-1), Acc = PVector(0.0 m s^-2, 0.0 m s^-2, 0.0 m s^-2), Mass = 1000.0 gjulia> extent(p)Extent: xMin = -1.0 m, xMax = 1.0 m, yMin = -1.0 m, yMax = 1.0 m, zMin = -1.0 m, zMax = 1.0 m, SideLength = 2.0 m, Center = PVector(0.0 m, 0.0 m, 0.0 m)
or by comparing two Extents and even array of Extents:
# 5 methods for generic function "extent":
[1] extent(a::Array{T,N}) where {N, T<:Union{AbstractParticle2D, PVector2D}}
[2] extent(a::Array{T,N}) where {N, T<:Union{AbstractParticle3D, PVector}}
[3] extent(a::Extent2D, b::Extent2D)
[4] extent(a::Extent, b::Extent)
[5] extent(a::Array{T,N} where N) where T<:AbstractExtent
For particles with masses, compute the mass center with:
julia> mass_center(p)PVector(0.0 m, 0.0 m, 0.0 m)
Minimum, maximum and center
The computation of Extents are based on a series of small functions, we use p defined in previous section to demonstrate:
julia> center(p)PVector(0.0 m, 0.0 m, 0.0 m)
We have implemented max_x, max_y, max_z, min_x, min_y, min_z, center, center_x, center_y, center_z for both points and particles. You could simply infer their functions by name.