spat v0.3.0 Spat.Geometry.Sphere
Link to this section Summary
Functions
Obtain the indexes of a sphere within the subdivided bounds
Check whether a sphere intersects with the given bounds (equal to or contained inside)
Link to this section Functions
Link to this function
index(origin, radius, bounds, subdivisions)
index(Spat.Coord.t(), number(), Spat.Bounds.t(), pos_integer()) :: [ Spat.grid_index() ]
Obtain the indexes of a sphere within the subdivided bounds.
iex> Spat.Geometry.Sphere.index({ 0 }, 1, Spat.Bounds.new({ 10 }), 1)
[[0]]
iex> Spat.Geometry.Sphere.index({ 5 }, 1, Spat.Bounds.new({ 10 }), 1)
[[0], [1]]
iex> Spat.Geometry.Sphere.index({ 10 }, 1, Spat.Bounds.new({ 10 }), 1)
[[1]]
iex> Spat.Geometry.Sphere.index({ -1 }, 1, Spat.Bounds.new({ 10 }), 1)
[]
iex> Spat.Geometry.Sphere.index({ 2.5 }, 1, Spat.Bounds.new({ 10 }), 1)
[[0]]
iex> Spat.Geometry.Sphere.index({ 2.5 }, 1, Spat.Bounds.new({ 10 }), 2)
[[0, 0], [0, 1]]
iex> Spat.Geometry.Sphere.index({ 5, 5 }, 1, Spat.Bounds.new({ 10, 10 }), 2)
[[0, 3], [1, 2], [2, 1], [3, 0]]
iex> Spat.Geometry.Sphere.index({ 2.5, 5 }, 1, Spat.Bounds.new({ 10, 10 }), 2)
[[0, 2], [0, 3], [2, 0], [2, 1]]
iex> Spat.Geometry.Sphere.index({ 0, 0 }, 1, Spat.Bounds.new({ 10, 10 }), 2)
[[0, 0]]
iex> Spat.Geometry.Sphere.index({ 0, 0 }, 20, Spat.Bounds.new({ 10, 10 }), 2)
[[0, 0], [0, 1], [0, 2], [0, 3], [1, 0], [1, 1], [1, 2], [1, 3], [2, 0], [2, 1], [2, 2], [2, 3], [3, 0], [3, 1], [3, 2], [3, 3]]
iex> Spat.Geometry.Sphere.index({ 12.5, 5 }, 1, Spat.Bounds.new({ 10, 0 }, { 20, 10 }), 2)
[[0, 2], [0, 3], [2, 0], [2, 1]]
iex> Spat.Geometry.Sphere.index({ 10, 0 }, 1, Spat.Bounds.new({ 10, 0 }, { 20, 10 }), 2)
[[0, 0]]
iex> Spat.Geometry.Sphere.index({ 0 }, 1, Spat.Bounds.new({ -10 }, { 10 }), 1)
[[0], [1]]
iex> Spat.Geometry.Sphere.index({ -5 }, 1, Spat.Bounds.new({ -10 }, { 10 }), 2)
[[0, 0], [0, 1]]
Link to this function
intersect(origin, radius, map)
intersect(Spat.Coord.t(), number(), Spat.Bounds.t()) :: boolean()
Check whether a sphere intersects with the given bounds (equal to or contained inside).