package ballistics.utils.math.equations

abstract class AbstractEquationCalculator {
    var iteration = 0
    var maxIterations = 20
    var delta = 0.001
    var value = 0.0

    abstract fun calculate(
        x1: Double,
        x2: Double,
        f: (Double) -> Double,
    ): Double?

    inline fun check(
        x1: Double,
        x2: Double,
        f: (Double) -> Double,
    ): Boolean {
        val y1 = f(x1)
        val y2 = f(x2)

        return ((y1 - value) * (y2 - value) <= 0)
    }
}
