Example #1
0
 /**
  * Applies the given transformation matrix to all points in the cloud.
  *
  * @param m transformation matrix
  * @return itself
  */
 public PointCloud3D applyMatrix(Matrix4x4 m) {
   for (Vec3D p : points) {
     p.set(m.applyTo(p));
   }
   updateBounds();
   return this;
 }
Example #2
0
 public PointCloud3D addPoint(Vec3D p) {
   points.add(p);
   min.minSelf(p);
   max.maxSelf(p);
   centroid.set(min.add(max).scaleSelf(0.5f));
   radiusSquared = MathUtils.max(radiusSquared, p.distanceToSquared(centroid));
   return this;
 }
Example #3
0
 /**
  * Recalculates the bounding box, bounding sphere and centroid of the cloud.
  *
  * @return itself
  */
 public PointCloud3D updateBounds() {
   min = Vec3D.MAX_VALUE.copy();
   max = Vec3D.NEG_MAX_VALUE.copy();
   for (Vec3D p : points) {
     min.minSelf(p);
     max.maxSelf(p);
   }
   centroid.set(min.add(max).scaleSelf(0.5f));
   radiusSquared = 0;
   for (ReadonlyVec3D p : points) {
     radiusSquared = MathUtils.max(radiusSquared, p.distanceToSquared(centroid));
   }
   return this;
 }