/** * Sets the observed value by coordinate point. * * @param x x-coordinate.-1 to 1 * @param y y-coordinate -1 to 1 * @param value Observed value at that coordinate */ public void setValue( int x , int y , double value ) { setValue((y+1)*3+x+1,value); }
/** * Impulse function with a peak at zero. should be no change */ @Test public void impulseAtZero() { FitQuadratic3by3 alg = new FitQuadratic3by3(); for( int i = -1; i <= 1; i++ ) { for( int j = -1; j <= 1; j++ ) { alg.setValue(j,i,2); } } alg.setValue(0,0,5); alg.process(); assertEquals(0,alg.getDeltaX(),1e-8); assertEquals(0,alg.getDeltaY(),1e-8); }
/** * skewed in an x-direction */ @Test public void skewedX() { FitQuadratic3by3 alg = new FitQuadratic3by3(); for( int i = -1; i <= 1; i++ ) { for( int j = -1; j <= 1; j++ ) { alg.setValue(j,i,2); } } alg.setValue(0,0,5); // give it larger values on the -1 side alg.setValue(-1, 0,4); alg.process(); assertTrue(alg.getDeltaX() < 0); assertTrue(alg.getDeltaX() >= -1); assertEquals(0,alg.getDeltaY(),1e-8); }
/** * skewed in an x-direction */ @Test public void skewedY() { FitQuadratic3by3 alg = new FitQuadratic3by3(); for( int i = -1; i <= 1; i++ ) { for( int j = -1; j <= 1; j++ ) { alg.setValue(j,i,2); } } alg.setValue(0,0,5); // give it larger values on the -1 side alg.setValue(0, -1,4); alg.process(); assertTrue(alg.getDeltaY() < 0); assertTrue(alg.getDeltaY() >= -1); assertEquals(0,alg.getDeltaX(),1e-8); }
/** * Sets the observed value by coordinate point. * * @param x x-coordinate.-1 to 1 * @param y y-coordinate -1 to 1 * @param value Observed value at that coordinate */ public void setValue( int x , int y , double value ) { setValue((y+1)*3+x+1,value); }