/** * 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; }
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; }
/** * 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; }