if (kernel == null) { return factory.createAffineTransform(CoordinateSystems.swapAndScaleAxes(source, target)); } else if (source.getDimension() == kernel.getSourceDimensions() + passthrough && target.getDimension() == kernel.getTargetDimensions() + passthrough) ? kernel.completeTransform(factory) : kernel.passthrough(factory); final MathTransform before = factory.createAffineTransform( CoordinateSystems.swapAndScaleAxes(source,
/** * Tests {@link CoordinateSystemTransform#create(MathTransformFactory, CoordinateSystem, CoordinateSystem)}. * for a conversion between two spherical coordinate systems. * * @throws FactoryException if an error occurred while creating the transform. * @throws TransformException if an error occurred while transforming the test point. */ @Test public void testSphericalToSpherical() throws FactoryException, TransformException { transform = CoordinateSystemTransform.create(factory, HardCodedCS.SPHERICAL, spherical); tolerance = 0; final double[][] data = SphericalToCartesianTest.testData(); final double[] source = data[0]; final double[] target = data[1]; System.arraycopy(source, 0, target, 0, source.length); for (int i=0; i<source.length; i += 3) { ArraysExt.swap(source, i, i+1); } verifyTransform(source, target); }
/** * Returns the cylindrical, including conversion between degrees and radians units. * This method is legal only for {@link PolarToCartesian} or {@link CartesianToPolar}. */ final MathTransform passthrough(final MathTransformFactory factory) throws FactoryException { MathTransform tr = passthrough; if (tr == null) { tr = factory.createPassThroughTransform(0, completeTransform(factory), 1); if (DefaultFactories.isDefaultInstance(MathTransformFactory.class, factory)) { // No need to synchronize since DefaultMathTransformFactory returns unique instances. passthrough = tr; } } return tr; }
/** * Tests {@link CoordinateSystemTransform#create(MathTransformFactory, CoordinateSystem, CoordinateSystem)}. * for a conversion from cylindrical to Cartesian coordinates. * * @throws FactoryException if an error occurred while creating the transform. * @throws TransformException if an error occurred while transforming the test point. */ @Test public void testCylindricalToCartesian() throws FactoryException, TransformException { tolerance = 1E-9; transform = CoordinateSystemTransform.create(factory, HardCodedCS.CYLINDRICAL, toCentimetres(HardCodedCS.CARTESIAN_3D)); final double[][] data = polarTestData(true); verifyTransform(data[0], data[1]); }
/** * Returns the cylindrical, including conversion between degrees and radians units. * This method is legal only for {@link PolarToCartesian} or {@link CartesianToPolar}. */ final MathTransform passthrough(final MathTransformFactory factory) throws FactoryException { MathTransform tr = passthrough; if (tr == null) { tr = factory.createPassThroughTransform(0, completeTransform(factory), 1); if (DefaultFactories.isDefaultInstance(MathTransformFactory.class, factory)) { // No need to synchronize since DefaultMathTransformFactory returns unique instances. passthrough = tr; } } return tr; }
/** * Tests {@link CoordinateSystemTransform#create(MathTransformFactory, CoordinateSystem, CoordinateSystem)}. * for a conversion from Cartesian to cylindrical coordinates. * * @throws FactoryException if an error occurred while creating the transform. * @throws TransformException if an error occurred while transforming the test point. */ @Test public void testCartesianToCylindrical() throws FactoryException, TransformException { tolerance = 1E-9; transform = CoordinateSystemTransform.create(factory, toCentimetres(HardCodedCS.CARTESIAN_3D), HardCodedCS.CYLINDRICAL); final double[][] data = polarTestData(true); verifyTransform(data[1], data[0]); }
if (kernel == null) { return factory.createAffineTransform(CoordinateSystems.swapAndScaleAxes(source, target)); } else if (source.getDimension() == kernel.getSourceDimensions() + passthrough && target.getDimension() == kernel.getTargetDimensions() + passthrough) ? kernel.completeTransform(factory) : kernel.passthrough(factory); final MathTransform before = factory.createAffineTransform( CoordinateSystems.swapAndScaleAxes(source,
/** * Tests {@link CoordinateSystemTransform#create(MathTransformFactory, CoordinateSystem, CoordinateSystem)}. * for a conversion from Cartesian to spherical coordinates. * * @throws FactoryException if an error occurred while creating the transform. * @throws TransformException if an error occurred while transforming the test point. */ @Test public void testCartesianToSpherical() throws FactoryException, TransformException { tolerance = 1E-9; transform = CoordinateSystemTransform.create(factory, toCentimetres(HardCodedCS.GEOCENTRIC), HardCodedCS.SPHERICAL); final double[][] data = sphericalTestData(); verifyTransform(data[1], data[0]); }
/** * Tests {@link CoordinateSystemTransform#create(MathTransformFactory, CoordinateSystem, CoordinateSystem)}. * for a conversion from polar to Cartesian coordinates. * * @throws FactoryException if an error occurred while creating the transform. * @throws TransformException if an error occurred while transforming the test point. */ @Test public void testPolarToCartesian() throws FactoryException, TransformException { tolerance = 1E-9; transform = CoordinateSystemTransform.create(factory, HardCodedCS.POLAR, toCentimetres(HardCodedCS.CARTESIAN_2D)); final double[][] data = polarTestData(false); verifyTransform(data[0], data[1]); }
/** * Tests {@link CoordinateSystemTransform#create(MathTransformFactory, CoordinateSystem, CoordinateSystem)}. * for a conversion from spherical to Cartesian coordinates. * * @throws FactoryException if an error occurred while creating the transform. * @throws TransformException if an error occurred while transforming the test point. */ @Test public void testSphericalToCartesian() throws FactoryException, TransformException { tolerance = 1E-9; transform = CoordinateSystemTransform.create(factory, HardCodedCS.SPHERICAL, toCentimetres(HardCodedCS.GEOCENTRIC)); final double[][] data = sphericalTestData(); verifyTransform(data[0], data[1]); }
/** * Tests {@link CoordinateSystemTransform#create(MathTransformFactory, CoordinateSystem, CoordinateSystem)}. * for a conversion from Cartesian to polar coordinates. * * @throws FactoryException if an error occurred while creating the transform. * @throws TransformException if an error occurred while transforming the test point. */ @Test public void testCartesianToPolar() throws FactoryException, TransformException { tolerance = 1E-9; transform = CoordinateSystemTransform.create(factory, toCentimetres(HardCodedCS.CARTESIAN_2D), HardCodedCS.POLAR); final double[][] data = polarTestData(false); verifyTransform(data[1], data[0]); } }
return CoordinateSystemTransform.create(this, source, target);
return CoordinateSystemTransform.create(this, source, target);