Skip to content

Instantly share code, notes, and snippets.

@mmatiaschek
Created February 24, 2018 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mmatiaschek/a26d7badf6b2feadf3924d7fe1fbe5b3 to your computer and use it in GitHub Desktop.
Save mmatiaschek/a26d7badf6b2feadf3924d7fe1fbe5b3 to your computer and use it in GitHub Desktop.
/**
* Calculates the min and max x, y and z (depth) from a point cloud buffer.
*/
private float calculateMinMaxPointCloudXYZ(FloatBuffer pointCloudBuffer, int numPoints) {
float current = 0;
if (numPoints != 0) {
int numFloats = 4 * numPoints;
int num = 0;
for (int i = 0; i<numFloats; i++) {
current = pointCloudBuffer.get(i);
if (num == 0) {
if (current > maxX){
maxX = current;
}
if (current < minX) {
minX = current;
}
}
if (num == 1) {
if (current > maxY){
maxY = current;
}
if (current < minY) {
minY = current;
}
}
if (num == 2) {
if (current > maxZ){
maxZ = current;
}
if (current < minZ) {
minZ = current;
}
}
if (num == 3) {
num = -1;
}
num++;
}
}
}
@mmatiaschek
Copy link
Author

minX: -3.44
maxX: -3.61

minY: -2.51
maxY: 2.77

minZ: 0.0
maxZ: 7.23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment