/**
 * Calculate the depth of field for a given aperture and distance.
 *
 * @param aperture The size of the lens opening, represented as a floating-point number.
 * @param distance The distance from the camera to the subject, represented as a floating-point number.
 *
 * @return The depth of field in meters.
 */
fun calculateDepthOfField(aperture: Double, distance: Double): Double {

    val focalLength = 50.0 // Assuming a 50mm lens

    val hyperfocalDistance = (focalLength * focalLength) / (aperture * 0.03)

    val frontFocusPoint = distance * hyperfocalDistance / (hyperfocalDistance + (distance - focalLength))

    val behindFocusPoint = distance * hyperfocalDistance / (hyperfocalDistance - (distance - focalLength))

    return when {
        frontFocusPoint >= 0 && behindFocusPoint >= 0 -> behindFocusPoint - frontFocusPoint
        frontFocusPoint < 0 -> behindFocusPoint
        behindFocusPoint < 0 -> frontFocusPoint
        else -> 0.0
    }
}
/**
 * Calculate the depth of field for a given aperture and distance.
 *
 * @param aperture The size of the lens opening, represented as a floating-point number.
 * @param distance The distance from the camera to the subject, represented as a floating-point number.
 *
 * @return The depth of field in meters.
 */
fun calculateDepthOfField(aperture: Double, distance: Double): Double {
/**
 * Calculate the depth of field for a given aperture and distance.
 *
 * @param aperture The size of the lens opening, represented as a floating-point number.
 * @param distance The distance from the camera to the subject, represented as a floating-point number.
 *
 * @return The depth of field in meters.
 */
fun calculateDepthOfField(aperture: Double, distance: Double): Double {

    val focalLength = 50.0 // Assuming a 50mm lens

    val hyperfocalDistance = (focalLength * focalLength) / (aperture * 0.03)

    val frontFocusPoint = distance * hyperfocalDistance / (hyperfocalDistance + (distance - focalLength))

    val behindFocusPoint = distance * hyperfocalDistance / (hyperfocalDistance - (distance - focalLength))

    return when {
        frontFocusPoint >= 0 && behindFocusPoint >= 0 -> behindFocusPoint - frontFocusPoint
        frontFocusPoint < 0 -> behindFocusPoint
        behindFocusPoint < 0 -> frontFocusPoint
        else -> 0.0
    }
}