MinieLibrary/src/main/java/com/jme3/bullet/animation/RagUtils.java
/**
     * Instantiate a compact RectangularSolid that bounds the sample locations
     * contained in a VectorSet.
     *
     * @param vectorSet the set of sample locations (not null, numVectors&gt;1,
     * contents unaffected)
     * @param scaleFactors to apply to local coordinates (not null, unaffected)
     * @return a new RectangularSolid
     */
Instantiate a compact RectangularSolid that bounds the sample locations
contained in a VectorSet.

@param vectorSet the set of sample locations (not null, numVectors>1,
contents unaffected)
@param scaleFactors to apply to local coordinates (not null, unaffected)
@return a new RectangularSolid
Instantiate a compact RectangularSolid that bounds the sample locations contained in a VectorSet . @param vectorSet the set of sample locations ( not null numVectors > 1 contents unaffected ) @param scaleFactors to apply to local coordinates ( not null unaffected ) @return a new RectangularSolid
static RectangularSolid makeRectangularSolid(VectorSet vectorSet,
            Vector3f scaleFactors) {
        int numVectors = vectorSet.numVectors();
        assert numVectors > 1 : numVectors;
        /*
         * Orient local axes based on the eigenvectors of the covariance matrix.
         */
        Matrix3f covariance = vectorSet.covariance(null);
        Eigen3f eigen = new Eigen3f(covariance);
        Vector3f[] basis = eigen.getEigenVectors();
        Quaternion localToWorld = new Quaternion();
        localToWorld.fromAxes(basis);
        Quaternion worldToLocal = localToWorld.inverse();
        /*
         * Calculate the min and max for each local axis.
         */
        Vector3f maxima = new Vector3f(Float.NEGATIVE_INFINITY,
                Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY);
        Vector3f minima = new Vector3f(Float.POSITIVE_INFINITY,
                Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY);
        Vector3f tempVector = new Vector3f();
        FloatBuffer buffer = vectorSet.toBuffer();
        buffer.rewind();
        while (buffer.hasRemaining()) {
            tempVector.x = buffer.get();
            tempVector.y = buffer.get();
            tempVector.z = buffer.get();
            worldToLocal.mult(tempVector, tempVector);
            MyVector3f.accumulateMaxima(maxima, tempVector);
            MyVector3f.accumulateMinima(minima, tempVector);
        }
        /*
         * Apply scale factors to local coordinates of extrema.
         */
        Vector3f center = MyVector3f.midpoint(minima, maxima, null);
        maxima.subtractLocal(center);
        maxima.multLocal(scaleFactors);
        maxima.addLocal(center);
        minima.subtractLocal(center);
        minima.multLocal(scaleFactors);
        minima.addLocal(center);
        RectangularSolid result
                = new RectangularSolid(minima, maxima, localToWorld);
        return result;
    }
static RectangularSolid makeRectangularSolid ( VectorSet vectorSet , Vector3f scaleFactors ) { int numVectors = vectorSet . numVectors ( ) ; assert numVectors > 1 : numVectors ; /*
         * Orient local axes based on the eigenvectors of the covariance matrix.
         */ Matrix3f covariance = vectorSet . covariance ( null ) ; Eigen3f eigen = new Eigen3f ( covariance ) ; Vector3f [ ] basis = eigen . getEigenVectors ( ) ; Quaternion localToWorld = new Quaternion ( ) ; localToWorld . fromAxes ( basis ) ; Quaternion worldToLocal = localToWorld . inverse ( ) ; /*
         * Calculate the min and max for each local axis.
         */ Vector3f maxima = new Vector3f ( Float . NEGATIVE_INFINITY , Float . NEGATIVE_INFINITY , Float . NEGATIVE_INFINITY ) ; Vector3f minima = new Vector3f ( Float . POSITIVE_INFINITY , Float . POSITIVE_INFINITY , Float . POSITIVE_INFINITY ) ; Vector3f tempVector = new Vector3f ( ) ; FloatBuffer buffer = vectorSet . toBuffer ( ) ; buffer . rewind ( ) ; while ( buffer . hasRemaining ( ) ) { tempVector . x = buffer . get ( ) ; tempVector . y = buffer . get ( ) ; tempVector . z = buffer . get ( ) ; worldToLocal . mult ( tempVector , tempVector ) ; MyVector3f . accumulateMaxima ( maxima , tempVector ) ; MyVector3f . accumulateMinima ( minima , tempVector ) ; } /*
         * Apply scale factors to local coordinates of extrema.
         */ Vector3f center = MyVector3f . midpoint ( minima , maxima , null ) ; maxima . subtractLocal ( center ) ; maxima . multLocal ( scaleFactors ) ; maxima . addLocal ( center ) ; minima . subtractLocal ( center ) ; minima . multLocal ( scaleFactors ) ; minima . addLocal ( center ) ; RectangularSolid result = new RectangularSolid ( minima , maxima , localToWorld ) ; return result ; }
Instantiate a compact RectangularSolid that bounds the sample locations
 contained in a VectorSet.
Instantiate a compact RectangularSolid that bounds the sample locations contained in a VectorSet .