new DefaultPassthroughPiecewiseTransform1DElement( "p0", RangeFactory.create(0.0, true, 1.0, true)); Assert.assertEquals(p0.getTargetDimensions(), 1); Assert.assertEquals(p0.getSourceDimensions(), 1); Assert.assertTrue(p0.isIdentity()); Assert.assertEquals(p0.inverse(), SingleDimensionTransformation.IDENTITY); Assert.assertEquals(p0.transform(0.5), 0.5, 0.0); Assert.assertEquals(p0.transform(new Position(0.5), null).getOrdinatePosition(), 0.5, 0.0); Assert.assertEquals( p0.inverse().transform(new Position(0.5), null).getOrdinatePosition(), 0.5, 0.0); final Position outDP = p0.transform(inDP, null); Assert.assertTrue(outDP.getOrdinatePosition() == 0.6); new DefaultPassthroughPiecewiseTransform1DElement("p1"); Assert.assertEquals(p1.getTargetDimensions(), 1); Assert.assertEquals(p1.getSourceDimensions(), 1); Assert.assertTrue(p1.isIdentity()); Assert.assertEquals(p1.inverse(), SingleDimensionTransformation.IDENTITY); Assert.assertEquals(p1.transform(0.5), 0.5, 0.0); Assert.assertEquals(p1.transform(111.5), 111.5, 0.0); Assert.assertEquals( p1.transform(new Position(123.5), null).getOrdinatePosition(), 123.5, 0.0); Assert.assertEquals( p1.inverse().transform(new Position(657.5), null).getOrdinatePosition(), 657.5, 0.0); final Position outDP1 = p1.transform(inDP1, null);
/** * Transforms the specified value. * * @param value The value to transform. * @return the transformed value. * @throws TransformationException if the value can't be transformed. */ public double transform(double value) throws TransformationException { if (checkContainment(value)) return value; throw new IllegalArgumentException("Wrong value:" + value); }
private boolean checkContainment(double value) throws TransformationException { return contains(value); }
/** * Creates a pass-through DefaultPiecewiseTransform1DElement. * * @param name for this {@link DomainElement1D}. * @param valueRange for this {@link DomainElement1D}. * @throws IllegalArgumentException */ public static DefaultPiecewiseTransform1DElement create(final CharSequence name, final Range valueRange) throws IllegalArgumentException { return new DefaultPassthroughPiecewiseTransform1DElement(name, valueRange); }
/** * Transforms the specified {@code ptSrc} and stores the result in {@code ptDst}. */ public Position transform(final Position ptSrc, Position ptDst) throws TransformationException { PiecewiseUtilities.ensureNonNull("DirectPosition", ptSrc); if (ptDst == null) { ptDst = new Position(); } final double value = ptSrc.getOrdinatePosition(); checkContainment(value); ptDst.setOrdinatePosition(transform(value)); return ptDst; }
/** * Creates a pass-through DefaultPiecewiseTransform1DElement. * * @param name for this {@link DomainElement1D}. * @param valueRange for this {@link DomainElement1D}. * @throws IllegalArgumentException */ public static DefaultPiecewiseTransform1DElement create(final CharSequence name, final Range valueRange) throws IllegalArgumentException { return new DefaultPassthroughPiecewiseTransform1DElement(name, valueRange); }
/** * Transforms the specified {@code ptSrc} and stores the result in {@code ptDst}. */ public Position transform(final Position ptSrc, Position ptDst) throws TransformationException { PiecewiseUtilities.ensureNonNull("DirectPosition", ptSrc); if (ptDst == null) { ptDst = new Position(); } final double value = ptSrc.getOrdinatePosition(); checkContainment(value); ptDst.setOrdinatePosition(transform(value)); return ptDst; }
final DefaultPassthroughPiecewiseTransform1DElement p0 = new DefaultPassthroughPiecewiseTransform1DElement( "p0", RangeFactory.create(0.0, true, 1.0, true, false)); Assert.assertEquals(p0.getTargetDimensions(), 1); Assert.assertEquals(p0.getSourceDimensions(), 1); Assert.assertTrue(p0.isIdentity()); Assert.assertEquals(p0.inverse(), SingleDimensionTransformation.IDENTITY); Assert.assertEquals(p0.transform(0.5), 0.5, 0.0); Assert.assertEquals(p0.inverse().transform(0.5), 0.5, 0.0); Assert.assertTrue(p0.transform(0.6) == 0.6); final DefaultPassthroughPiecewiseTransform1DElement p1 = new DefaultPassthroughPiecewiseTransform1DElement( "p1"); Assert.assertEquals(p1.getTargetDimensions(), 1); Assert.assertEquals(p1.getSourceDimensions(), 1); Assert.assertTrue(p1.isIdentity()); Assert.assertEquals(p1.inverse(), SingleDimensionTransformation.IDENTITY); Assert.assertEquals(p1.transform(0.5), 0.5, 0.0); Assert.assertEquals(p1.transform(111.5), 111.5, 0.0); Assert.assertEquals(p1.transform(123.5), 123.5, 0.0); Assert.assertEquals(p1.inverse().transform(657.5), 657.5, 0.0); Assert.assertTrue(p1.transform(0.6) == 0.6);
/** * Creates a pass-through DefaultPiecewiseTransform1DElement. * * @param name for this {@link DomainElement1D}. * @throws IllegalArgumentException */ public static DefaultPiecewiseTransform1DElement create(final CharSequence name) throws IllegalArgumentException { return new DefaultPassthroughPiecewiseTransform1DElement(name, RangeFactory.create( Double.NEGATIVE_INFINITY, true, Double.POSITIVE_INFINITY, true, true)); }
/** * Transforms the specified value. * * @param value The value to transform. * @return the transformed value. * @throws TransformationException if the value can't be transformed. */ public double transform(double value) throws TransformationException { if (checkContainment(value)) return value; throw new IllegalArgumentException("Wrong value:" + value); }
private boolean checkContainment(double value) throws TransformationException { return contains(value); }
/** * Creates a pass-through DefaultPiecewiseTransform1DElement. * * @param name for this {@link DomainElement1D}. * @throws IllegalArgumentException */ public static DefaultPiecewiseTransform1DElement create(final CharSequence name) throws IllegalArgumentException { return new DefaultPassthroughPiecewiseTransform1DElement(name, RangeFactory.create( Double.NEGATIVE_INFINITY, true, Double.POSITIVE_INFINITY, true, true)); }
this.elements = (E[]) new DefaultDomainElement1D[] { new DefaultPassthroughPiecewiseTransform1DElement( "p0") }; else
this.elements = (E[]) new DefaultDomainElement1D[] { new DefaultPassthroughPiecewiseTransform1DElement( "p0") }; else