Interface SpatialStructure<T>

Type Parameters:
T - the type of data stored in the structure.
All Known Implementing Classes:
KDTree

public interface SpatialStructure<T>
A spatial structure for organizing and accessing spatial data.
  • Method Summary

    Modifier and Type
    Method
    Description
    closest(org.joml.Vector3dc point)
    Gets the data closest to a point, or null if there is no data in the structure.
    void
    collect(org.joml.Vector3dc center, double radius, List<T> results)
    Gets all data that is within a specified spherical radius of a point, defined by center and radius.
    void
    collectBox(org.joml.Vector3dc min, org.joml.Vector3dc max, List<T> results)
    Gets all data that is within a specified axis-aligned box, defined by min and max positions.
    void
    collectCylinder(org.joml.Vector3dc center, double radius, double height, List<T> results)
    Gets all data that is within a specified cylindrical area, defined by a center point, radius, and height.
     
    void
    ordered(org.joml.Vector3dc center, double radius, List<T> results)
    Gets all data that is within a specified radius of a point in order of closest to furthest.
    void
    ordered3DAxis(org.joml.Vector3dc center, double xSearchRadius, double ySearchRadius, double zSearchRadius, List<T> results)
    Gets all data that is within specified radius along each axis of a point.
    void
    Builds the structure using the provided data.
    int
     
  • Method Details

    • size

      int size()
      Returns:
      the number of pieces of data in the structure.
    • rebuild

      void rebuild(@Nonnull SpatialData<T> data)
      Builds the structure using the provided data. This clears any existing data in the structure.
      Parameters:
      data - The data to build the structure with.
    • closest

      @Nullable T closest(@Nonnull org.joml.Vector3dc point)
      Gets the data closest to a point, or null if there is no data in the structure.
      Parameters:
      point - The point to search from.
      Returns:
      the data closest to the provided point, or null if there is no data in the structure.
    • collect

      void collect(@Nonnull org.joml.Vector3dc center, double radius, @Nonnull List<T> results)
      Gets all data that is within a specified spherical radius of a point, defined by center and radius.
      Parameters:
      center - The center of the sphere.
      radius - The radius of the sphere.
      results - The list to populate with results.
    • collectCylinder

      void collectCylinder(@Nonnull org.joml.Vector3dc center, double radius, double height, @Nonnull List<T> results)
      Gets all data that is within a specified cylindrical area, defined by a center point, radius, and height.
      Parameters:
      center - The center point of the cylinder's base.
      radius - The radius of the cylinder.
      height - The height of the cylinder.
      results - The list to populate with results.
    • collectBox

      void collectBox(@Nonnull org.joml.Vector3dc min, @Nonnull org.joml.Vector3dc max, @Nonnull List<T> results)
      Gets all data that is within a specified axis-aligned box, defined by min and max positions.
      Parameters:
      min - The minimum corner of the box (inclusive).
      max - The maximum corner of the box (inclusive).
      results - The list to populate with results.
    • ordered

      void ordered(@Nonnull org.joml.Vector3dc center, double radius, @Nonnull List<T> results)
      Gets all data that is within a specified radius of a point in order of closest to furthest.

      If the use case doesn't require the order then please use collect(Vector3dc, double, List) instead.

      Parameters:
      center - The center point from which to search.
      radius - The radius of the search.
      results - The list to populate with results, ordered from closest to furthest.
    • ordered3DAxis

      void ordered3DAxis(@Nonnull org.joml.Vector3dc center, double xSearchRadius, double ySearchRadius, double zSearchRadius, @Nonnull List<T> results)
      Gets all data that is within specified radius along each axis of a point.
      Parameters:
      center - The center point from which to search.
      xSearchRadius - The search radius along the X axis.
      ySearchRadius - The search radius along the Y axis.
      zSearchRadius - The search radius along the Z axis.
      results - The output list to store data within the specified radius, ordered from closest to furthest.
    • dump

      @Nonnull String dump()
      Returns:
      an information dump of this spatial structure, for debugging purposes.