/**
 * 
 * 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.xyz.generator;

/**
 * Generator function that generates a gauss distribution
 * @author ebner
 *
 */
public class Gauss2D implements XYZGeneratorFunction{
	
	private double centerX;
	private double centerY;
	private double sigmaX;
	private double sigmaY;
	private double amplitude;
	
	/**
	 * Constructor
	 * @param centerX
	 * @param centerY
	 * @param sigmaX
	 * @param sigmaY
	 * @param amplitude
	 */
	public Gauss2D(double centerX, double centerY, double sigmaX, double sigmaY, double amplitude){
		this.centerX = centerX;
		this.centerY = centerY;
		this.sigmaX = sigmaX;
		this.sigmaY = sigmaY;
		this.amplitude = amplitude;
	}
	
	
	@Override
	public double generate(double x, double y) {
		return amplitude*Math.exp(-Math.pow(x - centerX, 2.0)/sigmaX)* Math.exp(-Math.pow(y - centerY, 2.0)/sigmaY);
	}
	
}
