fuookami.ospf.kotlin.utils.physics.quantity.Quantity.kt Maven / Gradle / Ivy
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")
}
}
infix fun Quantity.eq(other: Quantity): Boolean where V : Arithmetic, V: Eq {
return if (this.unit == other.unit) {
this.value eq other.value
} else if (this.unit.quantity == other.unit.quantity) {
TODO("not implemented yet")
} else {
false
}
}
infix fun Quantity.partialOrd(other: Quantity): Order? where V : Arithmetic, V: PartialOrd {
return if (this.unit == other.unit) {
this.value partialOrd other.value
} else if (this.unit.quantity == other.unit.quantity) {
TODO("not implemented yet")
} else {
null
}
}
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")
}
}