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

fuookami.ospf.kotlin.utils.physics.quantity.Quantity.kt Maven / Gradle / Ivy

There is a newer version: 1.0.29
Show newest version
package fuookami.ospf.kotlin.utils.physics.quantity

import fuookami.ospf.kotlin.utils.math.*
import fuookami.ospf.kotlin.utils.operator.*
import fuookami.ospf.kotlin.utils.physics.unit.*

data class Quantity>(
    val value: V,
    val unit: PhysicalUnit
) {
    fun to(unit: PhysicalUnit): Quantity {
        TODO("not implemented yet")
    }
}

operator fun > V.times(unit: PhysicalUnit): Quantity {
    return Quantity(this, unit)
}

operator fun  Quantity.plus(other: Quantity): Quantity where V : Arithmetic, V : Plus {
    return if (this.unit == other.unit) {
        Quantity(this.value + other.value, this.unit)
    } else if (this.unit.quantity == other.unit.quantity) {
        TODO("not implemented yet")
    } else {
        TODO("not implemented yet")
    }
}

operator fun  Quantity.minus(other: Quantity): Quantity where V : Arithmetic, V : Minus {
    return if (this.unit == other.unit) {
        Quantity(this.value - other.value, this.unit)
    } else if (this.unit.quantity == other.unit.quantity) {
        TODO("not implemented yet")
    } else {
        TODO("not implemented yet")
    }
}

operator fun  Quantity.times(other: Quantity): Quantity where V : Arithmetic, V : Times {
    return if (this.unit.quantity == other.unit.quantity) {
        Quantity(this.value * other.value, this.unit * other.unit)
    } else {
        TODO("not implemented yet")
    }
}

operator fun  Quantity.div(other: Quantity): Quantity where V : Arithmetic, V : Div {
    return if (this.unit.quantity == other.unit.quantity) {
        Quantity(this.value / other.value, this.unit / other.unit)
    } else {
        TODO("not implemented yet")
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy