@Test public void testCone() { final Matrix4d cone = new Matrix4d( 1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 0, 0, -1); IMAGE_J.op().run(QuadricToEllipsoid.class, cone); final Optional<Ellipsoid> result = quadricToEllipsoid.calculate(cone); assertFalse(result.isPresent()); }
@Override public Optional<Ellipsoid> calculate(final Matrix4dc quadricSolution) { final Vector3dc center = findCenter(quadricSolution); final Matrix4dc translated = translateToCenter(quadricSolution, center); final EigenDecomposition decomposition = solveEigenDecomposition( translated); final boolean invalidEv = Arrays.stream(decomposition.getRealEigenvalues()) .anyMatch(e -> e <= 0.0); if (invalidEv) { return Optional.empty(); } final double[] radii = Arrays.stream(decomposition.getRealEigenvalues()) .map(ev -> Math.sqrt(1.0 / ev)).toArray(); final Ellipsoid ellipsoid = new Ellipsoid(radii[0], radii[1], radii[2]); ellipsoid.setCentroid(center); final Matrix3dc orientation = toOrientationMatrix(decomposition); ellipsoid.setOrientation(orientation); return Optional.of(ellipsoid); }
QuadricToEllipsoid extends
	AbstractUnaryFunctionOp<Matrix4dc, Optional<Ellipsoid>> { @Override public Optional<Ellipsoid> calculate(final Matrix4dc quadricSolution) { final Vector3dc center = findCenter(quadricSolution); final Matrix4dc translated = translateToCenter(quadricSolution, center); final EigenDecomposition decomposition = solveEigenDecomposition( translated); final boolean invalidEv = Arrays.stream(decomposition.getRealEigenvalues()) .anyMatch(e -> e <= 0.0); if (invalidEv) { return Optional.empty(); } final double[] radii = Arrays.stream(decomposition.getRealEigenvalues()) .map(ev -> Math.sqrt(1.0 / ev)).toArray(); final Ellipsoid ellipsoid = new Ellipsoid(radii[0], radii[1], radii[2]); ellipsoid.setCentroid(center); final Matrix3dc orientation = toOrientationMatrix(decomposition); ellipsoid.setOrientation(orientation); return Optional.of(ellipsoid); } }
QuadricToEllipsoid extends
	AbstractUnaryFunctionOp<Matrix4dc, Optional<Ellipsoid>> { @Override public Optional<Ellipsoid> calculate(final Matrix4dc quadricSolution) { final Vector3dc center = findCenter(quadricSolution); final Matrix4dc translated = translateToCenter(quadricSolution, center); final EigenDecomposition decomposition = solveEigenDecomposition( translated); final boolean invalidEv = Arrays.stream(decomposition.getRealEigenvalues()) .anyMatch(e -> e <= 0.0); if (invalidEv) { return Optional.empty(); } final double[] radii = Arrays.stream(decomposition.getRealEigenvalues()) .map(ev -> Math.sqrt(1.0 / ev)).toArray(); final Ellipsoid ellipsoid = new Ellipsoid(radii[0], radii[1], radii[2]); ellipsoid.setCentroid(center); final Matrix3dc orientation = toOrientationMatrix(decomposition); ellipsoid.setOrientation(orientation); return Optional.of(ellipsoid); }  }
QuadricToEllipsoid extends
	AbstractUnaryFunctionOp<Matrix4dc, Optional<Ellipsoid>> { @Override public Optional<Ellipsoid> calculate(final Matrix4dc quadricSolution) { final Vector3dc center = findCenter(quadricSolution); final Matrix4dc translated = translateToCenter(quadricSolution, center); final EigenDecomposition decomposition = solveEigenDecomposition( translated); final boolean invalidEv = Arrays.stream(decomposition.getRealEigenvalues()) .anyMatch(e -> e <= 0.0); if (invalidEv) { return Optional.empty(); } final double[] radii = Arrays.stream(decomposition.getRealEigenvalues()) .map(ev -> Math.sqrt(1.0 / ev)).toArray(); final Ellipsoid ellipsoid = new Ellipsoid(radii[0], radii[1], radii[2]); ellipsoid.setCentroid(center); final Matrix3dc orientation = toOrientationMatrix(decomposition); ellipsoid.setOrientation(orientation); return Optional.of(ellipsoid); }  @Override Optional<Ellipsoid> calculate(final Matrix4dc quadricSolution); }
QuadricToEllipsoid extends
	AbstractUnaryFunctionOp<Matrix4dc, Optional<Ellipsoid>> { @Override public Optional<Ellipsoid> calculate(final Matrix4dc quadricSolution) { final Vector3dc center = findCenter(quadricSolution); final Matrix4dc translated = translateToCenter(quadricSolution, center); final EigenDecomposition decomposition = solveEigenDecomposition( translated); final boolean invalidEv = Arrays.stream(decomposition.getRealEigenvalues()) .anyMatch(e -> e <= 0.0); if (invalidEv) { return Optional.empty(); } final double[] radii = Arrays.stream(decomposition.getRealEigenvalues()) .map(ev -> Math.sqrt(1.0 / ev)).toArray(); final Ellipsoid ellipsoid = new Ellipsoid(radii[0], radii[1], radii[2]); ellipsoid.setCentroid(center); final Matrix3dc orientation = toOrientationMatrix(decomposition); ellipsoid.setOrientation(orientation); return Optional.of(ellipsoid); }  @Override Optional<Ellipsoid> calculate(final Matrix4dc quadricSolution);  }