All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.functions.OpticsFunctions.kt Maven / Gradle / Ivy

The newest version!
package org.openrndr.orsl.shadergenerator.phrases.dsl.functions.extra

import org.openrndr.orsl.shadergenerator.dsl.ShaderBuilder
import org.openrndr.orsl.shadergenerator.dsl.Symbol
import org.openrndr.orsl.shadergenerator.dsl.functions.function

/**
 * Calculate the circle of confusion
 * @param aperture unitless aperture of the lens
 * @param focalLength unitless focal length of the lens
 * @param focus unitless distance at which the lens is focussed
 * @param distance unitless distance at which the object is placed
 */
fun ShaderBuilder.coc(
    aperture: Symbol,
    focalLength: Symbol,
    focus: Symbol,
    distance: Symbol
): Symbol {
    val coc by function { a, f, zf, z ->
        abs((a * f * (zf - z)) / (zf * (z - f)))
    }
    return coc(aperture, focalLength, focus, distance)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy