AvogadroLibs 1.97.0
Public Member Functions | Protected Attributes | List of all members
NeighborPerceiver Class Reference

This class can be used to find physically neighboring points in linear average time.

#include <avogadro/core/neighborperceiver.h>

Public Member Functions

 NeighborPerceiver (const Array< Vector3 > points, float maxDistance)
 
Array< IndexgetNeighborsInclusive (const Vector3 &point) const
 
void getNeighborsInclusiveInPlace (Array< Index > &out, const Vector3 &point) const
 

Protected Attributes

float m_maxDistance
 
std::array< int, 3 > m_binCount
 
std::vector< std::vector< std::vector< std::vector< Index > > > > m_bins
 
Vector3 m_minPos
 
Vector3 m_maxPos
 

Constructor & Destructor Documentation

◆ NeighborPerceiver()

NeighborPerceiver ( const Array< Vector3 >  points,
float  maxDistance 
)

Creates a NeighborPerceiver that detects neighbors up to at least some distance.

Parameters
pointsPositions in 3D space to detect neighbors among.
maxDistanceAll neighbors strictly within this distance will be detected. Should be as low as possible for best performance.

Member Function Documentation

◆ getNeighborsInclusive()

Array< Index > getNeighborsInclusive ( const Vector3 &  point) const

Returns a list of neighboring points. Linear time to number of neighbors. Can include some neighbors up to 2*sqrt(3) times the maximum distance. The list is newly allocated on every call; if performance/fragmentation is a concern, prefer NeighborPerceiver::getNeighborsInclusiveInPlace().

Parameters
pointPosition to return neighbors of, can be located anywhere.

◆ getNeighborsInclusiveInPlace()

void getNeighborsInclusiveInPlace ( Array< Index > &  out,
const Vector3 &  point 
) const

Fills an array with all neighboring points. Linear time to number of neighbors. Can include some neighbors up to 2*sqrt(3) times the maximum distance.

Parameters
outArray to output neighbor indices in.
pointPosition to return neighbors of, can be located anywhere.

The documentation for this class was generated from the following file: