package fusionOptics.optimisationMulti;

import fusionOptics.Util;
import fusionOptics.surfaces.Dish;
import fusionOptics.types.Element;

public class BendableDish extends Parameter {
	
	/** The dish to bend */
	private Dish dish;
	
	public BendableDish(Dish dish, double min, double max) {
		super(min, max); //parameter is relative to the initial bounding sphere centre, so starts at 0
		this.dish = dish;
		this.initVal = get();
	}
	
	public BendableDish(Dish dish, double fractionChange) {
		this.dish = dish; 
		this.min = (1.0 - fractionChange) * dish.getRadiusOfCurv();
		this.max = (1.0 + fractionChange) * dish.getRadiusOfCurv();
		this.initVal = get();
	}
	
	@Override
	public String toString() { 
		return "BendableDish["+dish.getName()+"]: init = " + initVal() + "current="+get()+", min = " + min() + ", max = " + max();
	}
	
	@Override
	public double get() { //distance from init pos along the given vector
		return dish.getRadiusOfCurv()/scale;
	}
	
	@Override
	public void set(double val) {
		dish.setRadiusOfCurv(val*scale);
	}
	
	
}
