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

io.data2viz.geo.Math.kt Maven / Gradle / Ivy

There is a newer version: 0.8.0-RC5
Show newest version
package io.data2viz.geo

import io.data2viz.math.HALFPI
import io.data2viz.math.PI
import kotlin.math.acos
import kotlin.math.asin

val Double.asin: Double
    get() = limitedAsin(this)

val Double.acos: Double
    get() = limitedAcos(this)

private fun limitedAsin(value: Double): Double {
    return when {
        value > 1 -> HALFPI
        value < -1 -> -HALFPI
        else -> asin(value)
    }
}

private fun limitedAcos(value: Double): Double {
    return when {
        value > 1 -> .0
        value < -1 -> PI
        else -> acos(value)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy