/*
 * $URL$
 * $Revision$
 * $LastChangedBy$
 * $LastChangedDate$
 *
 * Copyright (c) 2005 syseca AG, Switzerland
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of syseca AG. ("Confidential Information"). You shall not
 * disclose such Confidential Information and shall use it only
 * in accordance with the terms of the license agreement you
 * entered into with syseca AG.
 */
package ch.spherIC;

/**
 * Class representing the Exposure Values formula <code>2^EV = f^2 / t</code>.
 *
 * <p>With:<br>
 * EV = Exposure Value<br>
 * f = Aperture<br>
 * t = shutter speed</p>
 */
public class EVFormula {

    /**
     * Calculates the exposure value <code>EV</code> from aperture <code>f</code> and shutter speed <code>t</code>.
     *
     * <p>EV = (2 * log f - log t) / log 2</p>
     *
     * @param   aperture     Aperture value
     * @param   sutterSpeed  Shutter speed value
     *
     * @return  Calculated Exposure value
     */
    public static double calcEV(double aperture, double shutterSpeed) {

        return (2 * Math.log10(aperture) - Math.log10(shutterSpeed)) / Math.log10(2f);
    }

    /**
     * Calculates the shutter speed <code>t</code> from aperture <code>f</code> and exposure value <code>EV</code>.
     *
     * <p>t = f^2 / 2^EV</p>
     *
     * @param   aperture  Aperture value
     * @param   EV        Exposure value
     *
     * @return  Calculated Shutter speed value
     */
    public static double calcShutterSpeed(double aperture, double EV) {

        return (Math.pow(aperture, 2) / Math.pow(2, EV));
    }
}
