001/******************************************************************************* 002 * This software is provided as a supplement to the authors' textbooks on digital 003 * image processing published by Springer-Verlag in various languages and editions. 004 * Permission to use and distribute this software is granted under the BSD 2-Clause 005 * "Simplified" License (see http://opensource.org/licenses/BSD-2-Clause). 006 * Copyright (c) 2006-2016 Wilhelm Burger, Mark J. Burge. All rights reserved. 007 * Visit http://imagingbook.com for additional details. 008 *******************************************************************************/ 009 010package imagingbook.pub.geometry.mappings.nonlinear; 011 012import imagingbook.pub.geometry.mappings.Mapping; 013 014public class RippleMapping extends Mapping { 015 double xWavel = 20; 016 double yWavel = 100; 017 double xAmpl = 0; 018 double yAmpl = 10; 019 020 public RippleMapping ( 021 double xWavel, double xAmpl, 022 double yWavel, double yAmpl, 023 boolean inv) { 024 this.xWavel = xWavel / (2 * Math.PI); 025 this.yWavel = yWavel / (2 * Math.PI); 026 this.xAmpl = xAmpl; 027 this.yAmpl = yAmpl; 028 this.isInverseFlag = inv; 029 } 030 031 public static RippleMapping makeInverseMapping( 032 double xWavel, double xAmpl, double yWavel, double yAmpl){ 033 return new RippleMapping(xWavel, xAmpl, yWavel, yAmpl, true); 034 } 035 036 public double[] applyTo (double[] xy){ 037 double x0 = xy[0]; 038 double y0 = xy[1]; 039 double x1 = x0 + xAmpl * Math.sin(y0 / xWavel); 040 double y1 = y0 + yAmpl * Math.sin(x0 / yWavel); 041 //pnt.setLocation(x1, y1); 042 return new double[] {x1, y1}; 043 } 044} 045 046 047 048