CogniPilot

MODELICA LIBRARY · ENGINEERING REFERENCE

function

SLAM.Mapping.RGBDSpatialIndex.Bucket

Public declarations

Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.

RoleNameTypeDimensions / attributes / defaultDescription
inputcellInteger[3]
inputbucketCountInteger
outputbucketInteger

Modelica declarations and implementation

Show parameters, interfaces and source

Parameters, inputs, outputs, defaults and equations from the source file.

function Bucket
    input Integer cell[3];
    input Integer bucketCount;
    output Integer bucket;
  protected
    Integer hash;
  algorithm
    // The caller certifies 1..maximumBucketCount buckets. Reduce each key
    // before multiplication: the intermediate fits even a signed 32-bit Integer.
    hash := 0;
    for axis in 1:3 loop
      hash := mod(31*hash+mod(cell[axis],bucketCount),bucketCount);
    end for;
    bucket := hash+1;
  end Bucket;