/**
 * 
 * Copyright 2010 Paul Scherrer Institute. All rights reserved.
 * 
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This code is distributed in the hope that it will be useful,
 * but without any warranty; without even the implied warranty of
 * merchantability or fitness for a particular purpose. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this code. If not, see <http://www.gnu.org/licenses/>.
 * 
 */

package ch.psi.plot.xy.generator;

/**
 * Generator to generate absorption data
 * @author ebner
 *
 */
public class Absorption implements XYGeneratorFunction{
	
	@Override
	public double generate(double x) {
		
		final double startedge =10.0;
		final double frequency = 10.0;
		final double slope = 0.05;
		final double offset = 1.0;
		
		double y= offset - slope*x;
		if (x < startedge){
			return y;
		}
		else{
			return y + offset + 0.5*Math.exp(-(x-startedge))*Math.sin(frequency*(x-startedge));
		}
	}
}
