diff --git a/build.gradle b/build.gradle index 8f118f7..4134168 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ plugins { id "idea" id 'maven-publish' id "org.jetbrains.kotlin.jvm" version "1.6.10" - id "edu.wpi.first.GradleRIO" version "2023.1.1" + id "edu.wpi.first.GradleRIO" version "2023.2.1" id "com.diffplug.spotless" version "6.3.0" id "com.peterabeles.gversion" version "1.10" id "org.jetbrains.kotlinx.kover" version "0.4.2" @@ -33,8 +33,8 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib" - implementation "edu.wpi.first.wpimath:wpimath-java:2023.1.1" - implementation "edu.wpi.first.wpiutil:wpiutil-java:2023.1.1" + implementation "edu.wpi.first.wpimath:wpimath-java:2023.2.1" + implementation "edu.wpi.first.wpiutil:wpiutil-java:2023.2.1" implementation wpi.java.deps.wpilib() implementation wpi.java.vendor.java() @@ -51,7 +51,7 @@ publishing { release(MavenPublication) { groupId = 'org.team4099' artifactId = 'falconutils' - version = '1.0.6' + version = '1.1.0' from(components["kotlin"]) } diff --git a/src/main/kotlin/org/team4099/lib/Extensions.kt b/src/main/kotlin/org/team4099/lib/Extensions.kt index 223d6f5..802949f 100644 --- a/src/main/kotlin/org/team4099/lib/Extensions.kt +++ b/src/main/kotlin/org/team4099/lib/Extensions.kt @@ -13,7 +13,7 @@ import kotlin.math.min * @param tolerance The range within values will be considered near. * @return If [around] is within [tolerance] of this Double. */ -fun Double.around(around: Double, tolerance: Double): Boolean { +inline fun Double.around(around: Double, tolerance: Double): Boolean { return abs(this - around) < tolerance } @@ -24,7 +24,7 @@ fun Double.around(around: Double, tolerance: Double): Boolean { * @return This value adjusted to smoothly increase from zero if outside the deadband, zero if * inside the deadband. */ -fun Double.smoothDeadband(deadband: Double): Double { +inline fun Double.smoothDeadband(deadband: Double): Double { return if (abs(this) < deadband) { 0.0 } else { @@ -39,7 +39,7 @@ fun Double.smoothDeadband(deadband: Double): Double { * @param upperBound The upper bound of this Double's range. * @return Return this Double if it is in the range otherwise return [lowerBound] or [upperBound]. */ -fun Double.limit(lowerBound: Double, upperBound: Double): Double { +inline fun Double.limit(lowerBound: Double, upperBound: Double): Double { return min(upperBound, max(lowerBound, this)) } @@ -50,7 +50,7 @@ fun Double.limit(lowerBound: Double, upperBound: Double): Double { * @param upperBound The upper bound of this Int's range. * @return Return this Int if it is in the range otherwise return [lowerBound] or [upperBound]. */ -fun Int.limit(lowerBound: Int, upperBound: Int): Int { +inline fun Int.limit(lowerBound: Int, upperBound: Int): Int { return min(upperBound, max(lowerBound, this)) } @@ -63,7 +63,7 @@ fun Int.limit(lowerBound: Int, upperBound: Int): Int { * to between 0 and 1 inclusive. * @return A value between [a] and [b] determined by [x]. */ -fun interpolate(a: Double, b: Double, x: Double): Double { +inline fun interpolate(a: Double, b: Double, x: Double): Double { return a + (b - a) * x } @@ -76,6 +76,6 @@ fun interpolate(a: Double, b: Double, x: Double): Double { * to between 0 and 1 inclusive. * @return A value between [a] and [b] determined by [x]. */ -fun interpolate(a: Value, b: Value, x: Double): Value { +inline fun interpolate(a: Value, b: Value, x: Double): Value { return Value(a.value + (b.value - a.value) * x) } diff --git a/src/main/kotlin/org/team4099/lib/units/Derivatives.kt b/src/main/kotlin/org/team4099/lib/units/Derivatives.kt index 3c684b4..85f2d95 100644 --- a/src/main/kotlin/org/team4099/lib/units/Derivatives.kt +++ b/src/main/kotlin/org/team4099/lib/units/Derivatives.kt @@ -20,56 +20,56 @@ typealias LinearAcceleration = Value> typealias AngularAcceleration = Value> -val Value.perSecond +inline val Value.perSecond get() = Value>(value) -val Value.perMinute +inline val Value.perMinute get() = Value>(value / SECONDS_PER_MINUTE) -val LinearVelocity.inMetersPerSecond: Double +inline val LinearVelocity.inMetersPerSecond: Double get() = value -val LinearVelocity.inFeetPerSecond: Double +inline val LinearVelocity.inFeetPerSecond: Double get() = value / METERS_PER_FOOT -val LinearVelocity.inFeetPerMinute: Double +inline val LinearVelocity.inFeetPerMinute: Double get() = inFeetPerSecond * SECONDS_PER_MINUTE -val LinearVelocity.inInchesPerSecond: Double +inline val LinearVelocity.inInchesPerSecond: Double get() = value / METERS_PER_INCH -val AngularVelocity.inRadiansPerSecond: Double +inline val AngularVelocity.inRadiansPerSecond: Double get() = value -val AngularVelocity.inDegreesPerSecond: Double +inline val AngularVelocity.inDegreesPerSecond: Double get() = Math.toDegrees(value) -val AngularVelocity.inRotationsPerSecond: Double +inline val AngularVelocity.inRotationsPerSecond: Double get() = value / (2 * PI) -val AngularVelocity.inRotationsPerMinute: Double +inline val AngularVelocity.inRotationsPerMinute: Double get() = value * SECONDS_PER_MINUTE / (2 * PI) -val LinearAcceleration.inMetersPerSecondPerSecond: Double +inline val LinearAcceleration.inMetersPerSecondPerSecond: Double get() = value -val LinearAcceleration.inFeetPerSecondPerSecond: Double +inline val LinearAcceleration.inFeetPerSecondPerSecond: Double get() = value / METERS_PER_FOOT -val LinearAcceleration.inFeetPerMinutePerSecond: Double +inline val LinearAcceleration.inFeetPerMinutePerSecond: Double get() = inFeetPerSecondPerSecond * SECONDS_PER_MINUTE -val LinearAcceleration.inInchesPerSecondPerSecond: Double +inline val LinearAcceleration.inInchesPerSecondPerSecond: Double get() = value / METERS_PER_INCH -val AngularAcceleration.inRadiansPerSecondPerSecond: Double +inline val AngularAcceleration.inRadiansPerSecondPerSecond: Double get() = value -val AngularAcceleration.inDegreesPerSecondPerSecond: Double +inline val AngularAcceleration.inDegreesPerSecondPerSecond: Double get() = Math.toDegrees(value) -val AngularAcceleration.inRotationsPerSecondPerSecond: Double +inline val AngularAcceleration.inRotationsPerSecondPerSecond: Double get() = value / (2 * PI) -val AngularAcceleration.inRotationsPerMinutePerMinute: Double +inline val AngularAcceleration.inRotationsPerMinutePerMinute: Double get() = value * SECONDS_PER_MINUTE * SECONDS_PER_MINUTE / (2 * PI) diff --git a/src/main/kotlin/org/team4099/lib/units/Magnitude.kt b/src/main/kotlin/org/team4099/lib/units/Magnitude.kt index 7e33e25..5cef4e9 100644 --- a/src/main/kotlin/org/team4099/lib/units/Magnitude.kt +++ b/src/main/kotlin/org/team4099/lib/units/Magnitude.kt @@ -44,242 +44,242 @@ object Magnitude { const val YOCTO_INVERSE = 1E24 } -val Double.yotta: Double +inline val Double.yotta: Double get() = this * Magnitude.YOTTA -val Double.zeta: Double +inline val Double.zeta: Double get() = this * Magnitude.ZETA -val Double.exa: Double +inline val Double.exa: Double get() = this * Magnitude.EXA -val Double.peta: Double +inline val Double.peta: Double get() = this * Magnitude.PETA -val Double.tera: Double +inline val Double.tera: Double get() = this * Magnitude.TERA -val Double.giga: Double +inline val Double.giga: Double get() = this * Magnitude.GIGA -val Double.mega: Double +inline val Double.mega: Double get() = this * Magnitude.MEGA -val Double.kilo: Double +inline val Double.kilo: Double get() = this * Magnitude.KILO -val Double.hecto: Double +inline val Double.hecto: Double get() = this * Magnitude.HECTO -val Double.deca: Double +inline val Double.deca: Double get() = this * Magnitude.DECA -val Double.deci: Double +inline val Double.deci: Double get() = this * Magnitude.DECI -val Double.centi: Double +inline val Double.centi: Double get() = this * Magnitude.CENTI -val Double.milli: Double +inline val Double.milli: Double get() = this * Magnitude.MILLI -val Double.micro: Double +inline val Double.micro: Double get() = this * Magnitude.MICRO -val Double.nano: Double +inline val Double.nano: Double get() = this * Magnitude.NANO -val Double.pico: Double +inline val Double.pico: Double get() = this * Magnitude.PICO -val Double.femto: Double +inline val Double.femto: Double get() = this * Magnitude.FEMTO -val Double.atto: Double +inline val Double.atto: Double get() = this * Magnitude.ATTO -val Double.zepto: Double +inline val Double.zepto: Double get() = this * Magnitude.ZEPTO -val Double.yocto: Double +inline val Double.yocto: Double get() = this * Magnitude.YOCTO -val Number.yotta: Double +inline val Number.yotta: Double get() = this.toDouble() * Magnitude.YOTTA -val Number.zeta: Double +inline val Number.zeta: Double get() = this.toDouble() * Magnitude.ZETA -val Number.exa: Double +inline val Number.exa: Double get() = this.toDouble() * Magnitude.EXA -val Number.peta: Double +inline val Number.peta: Double get() = this.toDouble() * Magnitude.PETA -val Number.tera: Double +inline val Number.tera: Double get() = this.toDouble() * Magnitude.TERA -val Number.giga: Double +inline val Number.giga: Double get() = this.toDouble() * Magnitude.GIGA -val Number.mega: Double +inline val Number.mega: Double get() = this.toDouble() * Magnitude.MEGA -val Number.kilo: Double +inline val Number.kilo: Double get() = this.toDouble() * Magnitude.KILO -val Number.hecto: Double +inline val Number.hecto: Double get() = this.toDouble() * Magnitude.HECTO -val Number.deca: Double +inline val Number.deca: Double get() = this.toDouble() * Magnitude.DECA -val Number.deci: Double +inline val Number.deci: Double get() = this.toDouble() * Magnitude.DECI -val Number.centi: Double +inline val Number.centi: Double get() = this.toDouble() * Magnitude.CENTI -val Number.milli: Double +inline val Number.milli: Double get() = this.toDouble() * Magnitude.MILLI -val Number.micro: Double +inline val Number.micro: Double get() = this.toDouble() * Magnitude.MICRO -val Number.nano: Double +inline val Number.nano: Double get() = this.toDouble() * Magnitude.NANO -val Number.pico: Double +inline val Number.pico: Double get() = this.toDouble() * Magnitude.PICO -val Number.femto: Double +inline val Number.femto: Double get() = this.toDouble() * Magnitude.FEMTO -val Number.atto: Double +inline val Number.atto: Double get() = this.toDouble() * Magnitude.ATTO -val Number.zepto: Double +inline val Number.zepto: Double get() = this.toDouble() * Magnitude.ZEPTO -val Number.yocto: Double +inline val Number.yocto: Double get() = this.toDouble() * Magnitude.YOCTO -val Double.yottainverse: Double +inline val Double.yottainverse: Double get() = this * Magnitude.YOTTA_INVERSE -val Double.zetainverse: Double +inline val Double.zetainverse: Double get() = this * Magnitude.ZETA_INVERSE -val Double.exainverse: Double +inline val Double.exainverse: Double get() = this * Magnitude.EXA_INVERSE -val Double.petainverse: Double +inline val Double.petainverse: Double get() = this * Magnitude.PETA_INVERSE -val Double.terainverse: Double +inline val Double.terainverse: Double get() = this * Magnitude.TERA_INVERSE -val Double.gigainverse: Double +inline val Double.gigainverse: Double get() = this * Magnitude.GIGA_INVERSE -val Double.megainverse: Double +inline val Double.megainverse: Double get() = this * Magnitude.MEGA_INVERSE -val Double.kiloinverse: Double +inline val Double.kiloinverse: Double get() = this * Magnitude.KILO_INVERSE -val Double.hectoinverse: Double +inline val Double.hectoinverse: Double get() = this * Magnitude.HECTO_INVERSE -val Double.decainverse: Double +inline val Double.decainverse: Double get() = this * Magnitude.DECA_INVERSE -val Double.deciinverse: Double +inline val Double.deciinverse: Double get() = this * Magnitude.DECI_INVERSE -val Double.centiinverse: Double +inline val Double.centiinverse: Double get() = this * Magnitude.CENTI_INVERSE -val Double.milliinverse: Double +inline val Double.milliinverse: Double get() = this * Magnitude.MILLI_INVERSE -val Double.microinverse: Double +inline val Double.microinverse: Double get() = this * Magnitude.MICRO_INVERSE -val Double.nanoinverse: Double +inline val Double.nanoinverse: Double get() = this * Magnitude.NANO_INVERSE -val Double.picoinverse: Double +inline val Double.picoinverse: Double get() = this * Magnitude.PICO_INVERSE -val Double.femtoinverse: Double +inline val Double.femtoinverse: Double get() = this * Magnitude.FEMTO_INVERSE -val Double.attoinverse: Double +inline val Double.attoinverse: Double get() = this * Magnitude.ATTO_INVERSE -val Double.zeptoinverse: Double +inline val Double.zeptoinverse: Double get() = this * Magnitude.ZEPTO_INVERSE -val Double.yoctoinverse: Double +inline val Double.yoctoinverse: Double get() = this * Magnitude.YOCTO_INVERSE -val Number.yottainverse: Double +inline val Number.yottainverse: Double get() = this.toDouble() * Magnitude.YOTTA_INVERSE -val Number.zetainverse: Double +inline val Number.zetainverse: Double get() = this.toDouble() * Magnitude.ZETA_INVERSE -val Number.exainverse: Double +inline val Number.exainverse: Double get() = this.toDouble() * Magnitude.EXA_INVERSE -val Number.petainverse: Double +inline val Number.petainverse: Double get() = this.toDouble() * Magnitude.PETA_INVERSE -val Number.terainverse: Double +inline val Number.terainverse: Double get() = this.toDouble() * Magnitude.TERA_INVERSE -val Number.gigainverse: Double +inline val Number.gigainverse: Double get() = this.toDouble() * Magnitude.GIGA_INVERSE -val Number.megainverse: Double +inline val Number.megainverse: Double get() = this.toDouble() * Magnitude.MEGA_INVERSE -val Number.kiloinverse: Double +inline val Number.kiloinverse: Double get() = this.toDouble() * Magnitude.KILO_INVERSE -val Number.hectoinverse: Double +inline val Number.hectoinverse: Double get() = this.toDouble() * Magnitude.HECTO_INVERSE -val Number.decainverse: Double +inline val Number.decainverse: Double get() = this.toDouble() * Magnitude.DECA_INVERSE -val Number.deciinverse: Double +inline val Number.deciinverse: Double get() = this.toDouble() * Magnitude.DECI_INVERSE -val Number.centiinverse: Double +inline val Number.centiinverse: Double get() = this.toDouble() * Magnitude.CENTI_INVERSE -val Number.milliinverse: Double +inline val Number.milliinverse: Double get() = this.toDouble() * Magnitude.MILLI_INVERSE -val Number.microinverse: Double +inline val Number.microinverse: Double get() = this.toDouble() * Magnitude.MICRO_INVERSE -val Number.nanoinverse: Double +inline val Number.nanoinverse: Double get() = this.toDouble() * Magnitude.NANO_INVERSE -val Number.picoinverse: Double +inline val Number.picoinverse: Double get() = this.toDouble() * Magnitude.PICO_INVERSE -val Number.femtoinverse: Double +inline val Number.femtoinverse: Double get() = this.toDouble() * Magnitude.FEMTO_INVERSE -val Number.attoinverse: Double +inline val Number.attoinverse: Double get() = this.toDouble() * Magnitude.ATTO_INVERSE -val Number.zeptoinverse: Double +inline val Number.zeptoinverse: Double get() = this.toDouble() * Magnitude.ZEPTO_INVERSE -val Number.yoctoinverse: Double +inline val Number.yoctoinverse: Double get() = this.toDouble() * Magnitude.YOCTO_INVERSE diff --git a/src/main/kotlin/org/team4099/lib/units/UnitKey.kt b/src/main/kotlin/org/team4099/lib/units/UnitKey.kt index 030997d..5d98fe5 100644 --- a/src/main/kotlin/org/team4099/lib/units/UnitKey.kt +++ b/src/main/kotlin/org/team4099/lib/units/UnitKey.kt @@ -14,11 +14,11 @@ typealias Squared = Product typealias Cubed = Product> -val Double.unitless: Value +inline val Double.unitless: Value get() = Value(this) -val Number.unitless: Value +inline val Number.unitless: Value get() = this.toDouble().unitless -val Value.asDouble +inline val Value.asDouble get() = value diff --git a/src/main/kotlin/org/team4099/lib/units/base/Current.kt b/src/main/kotlin/org/team4099/lib/units/base/Current.kt index 91a4b34..d7c10d8 100644 --- a/src/main/kotlin/org/team4099/lib/units/base/Current.kt +++ b/src/main/kotlin/org/team4099/lib/units/base/Current.kt @@ -27,71 +27,71 @@ object Ampere : UnitKey typealias Current = Value -val Double.amps: Current +inline val Double.amps: Current get() = Current(this) -val Number.amps: Current +inline val Number.amps: Current get() = this.toDouble().amps -val Current.inAmperes +inline val Current.inAmperes get() = value -val Current.inYottaamps +inline val Current.inYottaamps get() = value * 1.yottainverse -val Current.inZetaamps +inline val Current.inZetaamps get() = value * 1.zetainverse -val Current.inExaamps +inline val Current.inExaamps get() = value * 1.exainverse -val Current.inPetaamps +inline val Current.inPetaamps get() = value * 1.petainverse -val Current.inTeraamps +inline val Current.inTeraamps get() = value * 1.terainverse -val Current.inGigaamps +inline val Current.inGigaamps get() = value * 1.gigainverse -val Current.inMegaamps +inline val Current.inMegaamps get() = value * 1.megainverse -val Current.inKiloamps +inline val Current.inKiloamps get() = value * 1.kiloinverse -val Current.inHectoamps +inline val Current.inHectoamps get() = value * 1.hectoinverse -val Current.inDecaamps +inline val Current.inDecaamps get() = value * 1.decainverse -val Current.inDeciamps +inline val Current.inDeciamps get() = value * 1.deciinverse -val Current.inCentiamps +inline val Current.inCentiamps get() = value * 1.centiinverse -val Current.inMilliamps +inline val Current.inMilliamps get() = value * 1.milliinverse -val Current.inMicroamps +inline val Current.inMicroamps get() = value * 1.microinverse -val Current.inNanoamps +inline val Current.inNanoamps get() = value * 1.nanoinverse -val Current.inPicoamps +inline val Current.inPicoamps get() = value * 1.picoinverse -val Current.inFemtoamps +inline val Current.inFemtoamps get() = value * 1.femtoinverse -val Current.inAttoamps +inline val Current.inAttoamps get() = value * 1.attoinverse -val Current.inZeptoamps +inline val Current.inZeptoamps get() = value * 1.zeptoinverse -val Current.inYoctoamps +inline val Current.inYoctoamps get() = value * 1.yoctoinverse diff --git a/src/main/kotlin/org/team4099/lib/units/base/Length.kt b/src/main/kotlin/org/team4099/lib/units/base/Length.kt index ee06231..28e7df6 100644 --- a/src/main/kotlin/org/team4099/lib/units/base/Length.kt +++ b/src/main/kotlin/org/team4099/lib/units/base/Length.kt @@ -27,104 +27,104 @@ object Meter : UnitKey typealias Length = Value -internal const val METERS_PER_INCH = 0.0254 +const val METERS_PER_INCH = 0.0254 -internal const val METERS_PER_THOU = METERS_PER_INCH / 1000 +const val METERS_PER_THOU = METERS_PER_INCH / 1000 -internal const val METERS_PER_FOOT = METERS_PER_INCH * 12 +const val METERS_PER_FOOT = METERS_PER_INCH * 12 -val Double.meters: Length +inline val Double.meters: Length get() = Length(this) -val Double.inches: Length +inline val Double.inches: Length get() = Length(this * METERS_PER_INCH) -val Double.thou: Length +inline val Double.thou: Length get() = Length(this * METERS_PER_THOU) -val Double.feet: Length +inline val Double.feet: Length get() = Length(this * METERS_PER_FOOT) -val Number.meters: Length +inline val Number.meters: Length get() = toDouble().meters -val Number.inches: Length +inline val Number.inches: Length get() = toDouble().inches -val Number.thou: Length +inline val Number.thou: Length get() = toDouble().thou -val Number.feet: Length +inline val Number.feet: Length get() = toDouble().feet -val Length.inMeters: Double +inline val Length.inMeters: Double get() = value -val Length.inInches: Double +inline val Length.inInches: Double get() = value / METERS_PER_INCH -val Length.inThou: Double +inline val Length.inThou: Double get() = value / METERS_PER_THOU -val Length.inFeet: Double +inline val Length.inFeet: Double get() = value / METERS_PER_FOOT -val Length.inYottameters: Double +inline val Length.inYottameters: Double get() = value * 1.yottainverse -val Length.inZetameters: Double +inline val Length.inZetameters: Double get() = value * 1.zetainverse -val Length.inExameters: Double +inline val Length.inExameters: Double get() = value * 1.exainverse -val Length.inPetameters: Double +inline val Length.inPetameters: Double get() = value * 1.petainverse -val Length.inTerameters: Double +inline val Length.inTerameters: Double get() = value * 1.terainverse -val Length.inGigameters: Double +inline val Length.inGigameters: Double get() = value * 1.gigainverse -val Length.inMegameters: Double +inline val Length.inMegameters: Double get() = value * 1.megainverse -val Length.inKilometers: Double +inline val Length.inKilometers: Double get() = value * 1.kiloinverse -val Length.inHectometers: Double +inline val Length.inHectometers: Double get() = value * 1.hectoinverse -val Length.inDecameters: Double +inline val Length.inDecameters: Double get() = value * 1.decainverse -val Length.inDecimeters: Double +inline val Length.inDecimeters: Double get() = value * 1.deciinverse -val Length.inCentimeters: Double +inline val Length.inCentimeters: Double get() = value * 1.centiinverse -val Length.inMillimeters: Double +inline val Length.inMillimeters: Double get() = value * 1.milliinverse -val Length.inMicrometers: Double +inline val Length.inMicrometers: Double get() = value * 1.microinverse -val Length.inNanometers: Double +inline val Length.inNanometers: Double get() = value * 1.nanoinverse -val Length.inPicometers: Double +inline val Length.inPicometers: Double get() = value * 1.picoinverse -val Length.inFemtometers: Double +inline val Length.inFemtometers: Double get() = value * 1.femtoinverse -val Length.inAttometers: Double +inline val Length.inAttometers: Double get() = value * 1.attoinverse -val Length.inZeptometers: Double +inline val Length.inZeptometers: Double get() = value * 1.zeptoinverse -val Length.inYoctometers: Double +inline val Length.inYoctometers: Double get() = value * 1.yoctoinverse diff --git a/src/main/kotlin/org/team4099/lib/units/base/Mass.kt b/src/main/kotlin/org/team4099/lib/units/base/Mass.kt index d26f8f1..7d2c64d 100644 --- a/src/main/kotlin/org/team4099/lib/units/base/Mass.kt +++ b/src/main/kotlin/org/team4099/lib/units/base/Mass.kt @@ -28,82 +28,82 @@ object Kilogram : UnitKey typealias Mass = Value -internal const val GRAMS_PER_POUND = 453.5924 +const val GRAMS_PER_POUND = 453.5924 -val Double.grams: Mass +inline val Double.grams: Mass get() = Mass(this / 1000) -val Double.pounds: Mass +inline val Double.pounds: Mass get() = Mass(this * GRAMS_PER_POUND / 1000) -val Number.grams: Mass +inline val Number.grams: Mass get() = toDouble().grams -val Number.pounds: Mass +inline val Number.pounds: Mass get() = toDouble().pounds -val Mass.inGrams: Double +inline val Mass.inGrams: Double get() = value * Magnitude.KILO -val Mass.inPounds: Double +inline val Mass.inPounds: Double get() = (value * Magnitude.KILO) / GRAMS_PER_POUND -val Mass.inYottagrams: Double +inline val Mass.inYottagrams: Double get() = (value * Magnitude.KILO) * 1.yottainverse -val Mass.inZetagrams: Double +inline val Mass.inZetagrams: Double get() = (value * Magnitude.KILO) * 1.zetainverse -val Mass.inExagrams: Double +inline val Mass.inExagrams: Double get() = (value * Magnitude.KILO) * 1.exainverse -val Mass.inPetagrams: Double +inline val Mass.inPetagrams: Double get() = (value * Magnitude.KILO) * 1.petainverse -val Mass.inTeragrams: Double +inline val Mass.inTeragrams: Double get() = (value * Magnitude.KILO) * 1.terainverse -val Mass.inGigagrams: Double +inline val Mass.inGigagrams: Double get() = (value * Magnitude.KILO) * 1.gigainverse -val Mass.inMegagrams: Double +inline val Mass.inMegagrams: Double get() = (value * Magnitude.KILO) * 1.megainverse -val Mass.inKilograms: Double +inline val Mass.inKilograms: Double get() = (value * Magnitude.KILO) * 1.kiloinverse -val Mass.inHectograms: Double +inline val Mass.inHectograms: Double get() = (value * Magnitude.KILO) * 1.hectoinverse -val Mass.inDecagrams: Double +inline val Mass.inDecagrams: Double get() = (value * Magnitude.KILO) * 1.decainverse -val Mass.inDecigrams: Double +inline val Mass.inDecigrams: Double get() = (value * Magnitude.KILO) * 1.deciinverse -val Mass.inCentigrams: Double +inline val Mass.inCentigrams: Double get() = (value * Magnitude.KILO) * 1.centiinverse -val Mass.inMilligrams: Double +inline val Mass.inMilligrams: Double get() = (value * Magnitude.KILO) * 1.milliinverse -val Mass.inMicrograms: Double +inline val Mass.inMicrograms: Double get() = (value * Magnitude.KILO) * 1.microinverse -val Mass.inNanograms: Double +inline val Mass.inNanograms: Double get() = (value * Magnitude.KILO) * 1.nanoinverse -val Mass.inPicograms: Double +inline val Mass.inPicograms: Double get() = (value * Magnitude.KILO) * 1.picoinverse -val Mass.inFemtograms: Double +inline val Mass.inFemtograms: Double get() = (value * Magnitude.KILO) * 1.femtoinverse -val Mass.inAttograms: Double +inline val Mass.inAttograms: Double get() = (value * Magnitude.KILO) * 1.attoinverse -val Mass.inZeptograms: Double +inline val Mass.inZeptograms: Double get() = (value * Magnitude.KILO) * 1.zeptoinverse -val Mass.inYoctograms: Double +inline val Mass.inYoctograms: Double get() = (value * Magnitude.KILO) * 1.yoctoinverse diff --git a/src/main/kotlin/org/team4099/lib/units/base/Temperature.kt b/src/main/kotlin/org/team4099/lib/units/base/Temperature.kt index 6bd4e94..d72f3b1 100644 --- a/src/main/kotlin/org/team4099/lib/units/base/Temperature.kt +++ b/src/main/kotlin/org/team4099/lib/units/base/Temperature.kt @@ -7,29 +7,29 @@ object Kelvin : UnitKey typealias Temperature = Value -val Double.kelvin: Temperature +inline val Double.kelvin: Temperature get() = Temperature(this) -val Double.celsius: Temperature +inline val Double.celsius: Temperature get() = Temperature(this + 273.15) -val Double.fahrenheit: Temperature +inline val Double.fahrenheit: Temperature get() = Temperature((this - 32) * 5.0 / 9.0 + 273.15) -val Number.kelvin: Temperature +inline val Number.kelvin: Temperature get() = toDouble().kelvin -val Number.celsius: Temperature +inline val Number.celsius: Temperature get() = toDouble().celsius -val Number.fahrenheit: Temperature +inline val Number.fahrenheit: Temperature get() = toDouble().fahrenheit -val Temperature.inKelvins: Double +inline val Temperature.inKelvins: Double get() = value -val Temperature.inCelsius: Double +inline val Temperature.inCelsius: Double get() = value - 273.15 -val Temperature.inFahrenheit: Double +inline val Temperature.inFahrenheit: Double get() = (value - 273.15) * 1.8 + 32 diff --git a/src/main/kotlin/org/team4099/lib/units/base/Time.kt b/src/main/kotlin/org/team4099/lib/units/base/Time.kt index 6e0c081..ded2eb6 100644 --- a/src/main/kotlin/org/team4099/lib/units/base/Time.kt +++ b/src/main/kotlin/org/team4099/lib/units/base/Time.kt @@ -17,63 +17,63 @@ object Second : UnitKey typealias Time = Value -internal const val SECONDS_PER_MINUTE = 60 +const val SECONDS_PER_MINUTE = 60 -internal const val SECONDS_PER_HOUR = SECONDS_PER_MINUTE * 60 +const val SECONDS_PER_HOUR = SECONDS_PER_MINUTE * 60 -val Double.seconds: Time +inline val Double.seconds: Time get() = Time(this) -val Double.minutes: Time +inline val Double.minutes: Time get() = Time(this * SECONDS_PER_MINUTE) -val Double.hours: Time +inline val Double.hours: Time get() = Time(this * SECONDS_PER_HOUR) -val Number.seconds: Time +inline val Number.seconds: Time get() = toDouble().seconds -val Number.minutes: Time +inline val Number.minutes: Time get() = toDouble().minutes -val Number.hours: Time +inline val Number.hours: Time get() = toDouble().hours -val Time.inSeconds: Double +inline val Time.inSeconds: Double get() = value -val Time.inMinutes: Double +inline val Time.inMinutes: Double get() = value / SECONDS_PER_MINUTE -val Time.inHours: Double +inline val Time.inHours: Double get() = value / SECONDS_PER_HOUR -val Time.inDeciseconds: Double +inline val Time.inDeciseconds: Double get() = value * 1.deciinverse -val Time.inCentiseconds: Double +inline val Time.inCentiseconds: Double get() = value * 1.centiinverse -val Time.inMilliseconds: Double +inline val Time.inMilliseconds: Double get() = value * 1.milliinverse -val Time.inMicroseconds: Double +inline val Time.inMicroseconds: Double get() = value * 1.microinverse -val Time.inNanoseconds: Double +inline val Time.inNanoseconds: Double get() = value * 1.nanoinverse -val Time.inPicoseconds: Double +inline val Time.inPicoseconds: Double get() = value * 1.picoinverse -val Time.inFemtoseconds: Double +inline val Time.inFemtoseconds: Double get() = value * 1.femtoinverse -val Time.inAttoseconds: Double +inline val Time.inAttoseconds: Double get() = value * 1.attoinverse -val Time.inZeptoseconds: Double +inline val Time.inZeptoseconds: Double get() = value * 1.zeptoinverse -val Time.inYoctoseconds: Double +inline val Time.inYoctoseconds: Double get() = value * 1.yoctoinverse diff --git a/src/main/kotlin/org/team4099/lib/units/derived/Angle.kt b/src/main/kotlin/org/team4099/lib/units/derived/Angle.kt index 0b0149d..96e0268 100644 --- a/src/main/kotlin/org/team4099/lib/units/derived/Angle.kt +++ b/src/main/kotlin/org/team4099/lib/units/derived/Angle.kt @@ -13,56 +13,56 @@ import kotlin.math.PI object Radian : UnitKey -internal const val RADIANS_PER_DEGREES = (2 * Math.PI) / 360 +const val RADIANS_PER_DEGREES = (2 * Math.PI) / 360 -internal const val RADIANS_PER_ROTATION = (2 * Math.PI) +const val RADIANS_PER_ROTATION = (2 * Math.PI) typealias Angle = Value -fun Angle(x: Double, y: Double): Angle { +inline fun Angle(x: Double, y: Double): Angle { return Rotation2dWPILIB(x, y).angle } -val Double.radians: Angle +inline val Double.radians: Angle get() = Angle(this) -val Double.degrees: Angle +inline val Double.degrees: Angle get() = Angle(Math.toRadians(this)) -val Double.rotations: Angle +inline val Double.rotations: Angle get() = Angle(this * 2 * Math.PI) -val Rotation2d.angle: Angle +inline val Rotation2d.angle: Angle get() = Angle(this.radians) -val Number.radians: Angle +inline val Number.radians: Angle get() = toDouble().radians -val Number.degrees: Angle +inline val Number.degrees: Angle get() = toDouble().degrees -val Number.rotations: Angle +inline val Number.rotations: Angle get() = toDouble().rotations -val Angle.inDegrees: Double +inline val Angle.inDegrees: Double get() = Math.toDegrees(value) -val Angle.inRadians: Double +inline val Angle.inRadians: Double get() = value -val Angle.inRotations: Double +inline val Angle.inRotations: Double get() = value / (2 * PI) -val Angle.inRotation2ds: Rotation2d +inline val Angle.inRotation2ds: Rotation2d get() = Rotation2d(value) -val Angle.sin: Double +inline val Angle.sin: Double get() = kotlin.math.sin(value) -val Angle.cos: Double +inline val Angle.cos: Double get() = kotlin.math.cos(value) -val Angle.tan: Double +inline val Angle.tan: Double get() = kotlin.math.tan(value) operator fun AngularVelocity.times(o: Length): LinearVelocity = (o * inRadiansPerSecond).perSecond diff --git a/src/main/kotlin/org/team4099/lib/units/derived/Characterization.kt b/src/main/kotlin/org/team4099/lib/units/derived/Characterization.kt index c4a18fe..306cee3 100644 --- a/src/main/kotlin/org/team4099/lib/units/derived/Characterization.kt +++ b/src/main/kotlin/org/team4099/lib/units/derived/Characterization.kt @@ -18,20 +18,20 @@ typealias AngularGravityFeedforward = Value> typealias LinearGravityFeedforward = Value -val Value.perMeterPerSecondPerSecond +inline val Value.perMeterPerSecondPerSecond get() = Value>>(value) -val Value.perRadianPerSecondPerSecond +inline val Value.perRadianPerSecondPerSecond get() = Value>>(value) -val AccelerationFeedforward.inVoltsPerRadianPerSecondPerSecond +inline val AccelerationFeedforward.inVoltsPerRadianPerSecondPerSecond get() = value -val AccelerationFeedforward.inVoltsPerMeterPerSecondPerSecond +inline val AccelerationFeedforward.inVoltsPerMeterPerSecondPerSecond get() = value -val AccelerationFeedforward.inAmpsPerRadianPerSecondPerSecond +inline val AccelerationFeedforward.inAmpsPerRadianPerSecondPerSecond get() = value -val AccelerationFeedforward.inAmpsPerMeterPerSecondPerSecond +inline val AccelerationFeedforward.inAmpsPerMeterPerSecondPerSecond get() = value diff --git a/src/main/kotlin/org/team4099/lib/units/derived/Charge.kt b/src/main/kotlin/org/team4099/lib/units/derived/Charge.kt index 26a3cfb..ee32adb 100644 --- a/src/main/kotlin/org/team4099/lib/units/derived/Charge.kt +++ b/src/main/kotlin/org/team4099/lib/units/derived/Charge.kt @@ -29,71 +29,71 @@ typealias Coulomb = Product typealias Charge = Value -val Double.coulombs +inline val Double.coulombs get() = Charge(this) -val Number.coulombs +inline val Number.coulombs get() = Charge(this.toDouble()) -val Charge.inCoulombs: Double +inline val Charge.inCoulombs: Double get() = value -val Charge.inYottacoulombs: Double +inline val Charge.inYottacoulombs: Double get() = value * 1.yottainverse -val Charge.inZetacoulombs: Double +inline val Charge.inZetacoulombs: Double get() = value * 1.zetainverse -val Charge.inExacoulombs: Double +inline val Charge.inExacoulombs: Double get() = value * 1.exainverse -val Charge.inPetacoulombs: Double +inline val Charge.inPetacoulombs: Double get() = value * 1.petainverse -val Charge.inTeracoulombs: Double +inline val Charge.inTeracoulombs: Double get() = value * 1.terainverse -val Charge.inGigacoulombs: Double +inline val Charge.inGigacoulombs: Double get() = value * 1.gigainverse -val Charge.inMegacoulombs: Double +inline val Charge.inMegacoulombs: Double get() = value * 1.megainverse -val Charge.inKilocoulombs: Double +inline val Charge.inKilocoulombs: Double get() = value * 1.kiloinverse -val Charge.inHectocoulombs: Double +inline val Charge.inHectocoulombs: Double get() = value * 1.hectoinverse -val Charge.inDecacoulombs: Double +inline val Charge.inDecacoulombs: Double get() = value * 1.decainverse -val Charge.inDecicoulombs: Double +inline val Charge.inDecicoulombs: Double get() = value * 1.deciinverse -val Charge.inCenticoulombs: Double +inline val Charge.inCenticoulombs: Double get() = value * 1.centiinverse -val Charge.inMillicoulombs: Double +inline val Charge.inMillicoulombs: Double get() = value * 1.milliinverse -val Charge.inMicrocoulombs: Double +inline val Charge.inMicrocoulombs: Double get() = value * 1.microinverse -val Charge.inNanocoulombs: Double +inline val Charge.inNanocoulombs: Double get() = value * 1.nanoinverse -val Charge.inPicocoulombs: Double +inline val Charge.inPicocoulombs: Double get() = value * 1.picoinverse -val Charge.inFemtocoulombs: Double +inline val Charge.inFemtocoulombs: Double get() = value * 1.femtoinverse -val Charge.inAttocoulombs: Double +inline val Charge.inAttocoulombs: Double get() = value * 1.attoinverse -val Charge.inZeptocoulombs: Double +inline val Charge.inZeptocoulombs: Double get() = value * 1.zeptoinverse -val Charge.inYoctocoulombs: Double +inline val Charge.inYoctocoulombs: Double get() = value * 1.yoctoinverse diff --git a/src/main/kotlin/org/team4099/lib/units/derived/Controller.kt b/src/main/kotlin/org/team4099/lib/units/derived/Controller.kt index 8a4411d..f953361 100644 --- a/src/main/kotlin/org/team4099/lib/units/derived/Controller.kt +++ b/src/main/kotlin/org/team4099/lib/units/derived/Controller.kt @@ -19,218 +19,218 @@ typealias IntegralGain = Value>> typealias DerivativeGain = Value>> -val Double.metersPerMeter +inline val Double.metersPerMeter get() = Value>(this) -val Double.metersPerSecondPerMetersPerSecond +inline val Double.metersPerSecondPerMetersPerSecond get() = Value, Velocity>>(this) -val Double.radiansPerSecondPerRadiansPerSecond +inline val Double.radiansPerSecondPerRadiansPerSecond get() = Value, Velocity>>(this) -val ProportionalGain>.inDegreesPerSecondPerDegree: Double +inline val ProportionalGain>.inDegreesPerSecondPerDegree: Double get() = value -val IntegralGain>.inDegreesPerSecondPerDegreeSeconds: Double +inline val IntegralGain>.inDegreesPerSecondPerDegreeSeconds: Double get() = value -val DerivativeGain>.inDegreesPerSecondPerDegreesPerSecond: Double +inline val DerivativeGain>.inDegreesPerSecondPerDegreesPerSecond: Double get() = value -val ProportionalGain>.inRadiansPerSecondPerRadian: Double +inline val ProportionalGain>.inRadiansPerSecondPerRadian: Double get() = value -val IntegralGain>.inRadiansPerSecondPerRadianSeconds: Double +inline val IntegralGain>.inRadiansPerSecondPerRadianSeconds: Double get() = value -val DerivativeGain>.inRadiansPerSecondPerRadiansPerSecond: Double +inline val DerivativeGain>.inRadiansPerSecondPerRadiansPerSecond: Double get() = value -val Value.metersPerMeter +inline val Value.metersPerMeter get() = Value>(value) -val Value.metersPerSecondPerMeterPerSecond +inline val Value.metersPerSecondPerMeterPerSecond get() = Value, Velocity>>(value) -val ProportionalGain>.inMetersPerSecondPerMeter +inline val ProportionalGain>.inMetersPerSecondPerMeter get() = value -val IntegralGain>.inMetersPerSecondPerMeterSecond +inline val IntegralGain>.inMetersPerSecondPerMeterSecond get() = value -val DerivativeGain>.inMetersPerSecondPerMetersPerSecond +inline val DerivativeGain>.inMetersPerSecondPerMetersPerSecond get() = value -val Value.perMeter +inline val Value.perMeter get() = Value>(value) -val Value.perInch +inline val Value.perInch get() = perMeter / METERS_PER_INCH -val Value.perFoot +inline val Value.perFoot get() = perMeter / METERS_PER_FOOT -val Value.perRadian +inline val Value.perRadian get() = Value>(value) -val Value.perDegree +inline val Value.perDegree get() = perRadian / RADIANS_PER_DEGREES -val Value.perRotation +inline val Value.perRotation get() = perRadian / RADIANS_PER_ROTATION -val Value.perMeterSeconds +inline val Value.perMeterSeconds get() = Value>>(value) -val Value.perInchSeconds +inline val Value.perInchSeconds get() = perMeterSeconds / METERS_PER_INCH -val Value.perFootSeconds +inline val Value.perFootSeconds get() = perMeterSeconds / METERS_PER_FOOT -val Value.perRadianSeconds +inline val Value.perRadianSeconds get() = Value>>(value) -val Value.perDegreeSeconds +inline val Value.perDegreeSeconds get() = perRadianSeconds / RADIANS_PER_DEGREES -val Value.perMeterPerSecond +inline val Value.perMeterPerSecond get() = Value>>(value) -val Value.perInchPerSecond +inline val Value.perInchPerSecond get() = perMeterPerSecond / METERS_PER_INCH -val Value.perFootPerSecond +inline val Value.perFootPerSecond get() = perMeterPerSecond / METERS_PER_FOOT -val Value.perRadianPerSecond +inline val Value.perRadianPerSecond get() = Value>>(value) -val Value.perDegreePerSecond +inline val Value.perDegreePerSecond get() = perRadianPerSecond / RADIANS_PER_DEGREES -val ProportionalGain.inVoltsPerMeter: Double +inline val ProportionalGain.inVoltsPerMeter: Double get() = value -val ProportionalGain.inVoltsPerInch: Double +inline val ProportionalGain.inVoltsPerInch: Double get() = inVoltsPerMeter * METERS_PER_INCH -val ProportionalGain.inVoltsPerFoot: Double +inline val ProportionalGain.inVoltsPerFoot: Double get() = inVoltsPerMeter * METERS_PER_FOOT -val ProportionalGain.inVoltsPerRadian: Double +inline val ProportionalGain.inVoltsPerRadian: Double get() = value -val ProportionalGain.inVoltsPerDegrees: Double +inline val ProportionalGain.inVoltsPerDegrees: Double get() = inVoltsPerRadian * RADIANS_PER_DEGREES -val ProportionalGain.inVoltsPerRotation: Double +inline val ProportionalGain.inVoltsPerRotation: Double get() = inVoltsPerRadian * RADIANS_PER_ROTATION -val ProportionalGain, Volt>.inVoltsPerMetersPerSecond: Double +inline val ProportionalGain, Volt>.inVoltsPerMetersPerSecond: Double get() = value -val ProportionalGain, Volt>.inVoltsPerRadiansPerSecond: Double +inline val ProportionalGain, Volt>.inVoltsPerRadiansPerSecond: Double get() = value -val IntegralGain.inVoltsPerMeterSeconds: Double +inline val IntegralGain.inVoltsPerMeterSeconds: Double get() = value -val IntegralGain.inVoltsPerInchSeconds: Double +inline val IntegralGain.inVoltsPerInchSeconds: Double get() = inVoltsPerMeterSeconds * METERS_PER_INCH -val IntegralGain.inVoltsPerFootSeconds: Double +inline val IntegralGain.inVoltsPerFootSeconds: Double get() = inVoltsPerMeterSeconds * METERS_PER_FOOT -val IntegralGain, Volt>.inVoltsPerMeters: Double +inline val IntegralGain, Volt>.inVoltsPerMeters: Double get() = value -val IntegralGain.inVoltsPerRadianSeconds: Double +inline val IntegralGain.inVoltsPerRadianSeconds: Double get() = value -val IntegralGain.inVoltsPerDegreeSeconds: Double +inline val IntegralGain.inVoltsPerDegreeSeconds: Double get() = inVoltsPerRadianSeconds * RADIANS_PER_DEGREES -val IntegralGain.inVoltsPerRotationsMinutes: Double +inline val IntegralGain.inVoltsPerRotationsMinutes: Double get() = inVoltsPerRadianSeconds * SECONDS_PER_MINUTE * RADIANS_PER_ROTATION -val IntegralGain, Volt>.inVoltsPerRadians: Double +inline val IntegralGain, Volt>.inVoltsPerRadians: Double get() = value -val DerivativeGain.inVoltsPerMeterPerSecond: Double +inline val DerivativeGain.inVoltsPerMeterPerSecond: Double get() = value -val DerivativeGain.inVoltsPerInchPerSecond: Double +inline val DerivativeGain.inVoltsPerInchPerSecond: Double get() = inVoltsPerMeterPerSecond * METERS_PER_INCH -val DerivativeGain.inVoltsPerFootPerSecond: Double +inline val DerivativeGain.inVoltsPerFootPerSecond: Double get() = inVoltsPerMeterPerSecond * METERS_PER_FOOT -val DerivativeGain, Volt>.inVoltsPerMetersPerSecondPerSecond: Double +inline val DerivativeGain, Volt>.inVoltsPerMetersPerSecondPerSecond: Double get() = value -val DerivativeGain.inVoltsPerRadianPerSecond: Double +inline val DerivativeGain.inVoltsPerRadianPerSecond: Double get() = value -val DerivativeGain.inVoltsPerDegreePerSecond: Double +inline val DerivativeGain.inVoltsPerDegreePerSecond: Double get() = inVoltsPerRadianPerSecond * RADIANS_PER_DEGREES -val DerivativeGain.inVoltsPerRotationsPerMinute: Double +inline val DerivativeGain.inVoltsPerRotationsPerMinute: Double get() = inVoltsPerRadianPerSecond * SECONDS_PER_MINUTE * RADIANS_PER_ROTATION -val DerivativeGain, Volt>.inVoltsPerRadiansPerSecondPerSecond: Double +inline val DerivativeGain, Volt>.inVoltsPerRadiansPerSecondPerSecond: Double get() = value -val ProportionalGain.inAmpsPerMeter: Double +inline val ProportionalGain.inAmpsPerMeter: Double get() = value -val ProportionalGain.inAmpsPerInch: Double +inline val ProportionalGain.inAmpsPerInch: Double get() = inAmpsPerMeter * METERS_PER_INCH -val ProportionalGain.inAmpsPerFoot: Double +inline val ProportionalGain.inAmpsPerFoot: Double get() = inAmpsPerMeter * METERS_PER_FOOT -val ProportionalGain.inAmpsPerRadian: Double +inline val ProportionalGain.inAmpsPerRadian: Double get() = value -val ProportionalGain.inAmpsPerDegrees: Double +inline val ProportionalGain.inAmpsPerDegrees: Double get() = inAmpsPerRadian * RADIANS_PER_DEGREES -val ProportionalGain.inAmpsPerRotation: Double +inline val ProportionalGain.inAmpsPerRotation: Double get() = inAmpsPerRadian * RADIANS_PER_ROTATION -val IntegralGain.inAmpsPerMeterSeconds: Double +inline val IntegralGain.inAmpsPerMeterSeconds: Double get() = value -val IntegralGain.inAmpsPerInchSeconds: Double +inline val IntegralGain.inAmpsPerInchSeconds: Double get() = inAmpsPerMeterSeconds * METERS_PER_INCH -val IntegralGain.inAmpsPerFootSeconds: Double +inline val IntegralGain.inAmpsPerFootSeconds: Double get() = inAmpsPerMeterSeconds * METERS_PER_FOOT -val IntegralGain.inAmpsPerRadianSeconds: Double +inline val IntegralGain.inAmpsPerRadianSeconds: Double get() = value -val IntegralGain.inAmpsPerDegreeSeconds: Double +inline val IntegralGain.inAmpsPerDegreeSeconds: Double get() = inAmpsPerRadianSeconds * RADIANS_PER_DEGREES -val IntegralGain.inAmpsPerRotationsMinutes: Double +inline val IntegralGain.inAmpsPerRotationsMinutes: Double get() = inAmpsPerRadianSeconds * SECONDS_PER_MINUTE * RADIANS_PER_ROTATION -val DerivativeGain.inAmpsPerMeterPerSecond: Double +inline val DerivativeGain.inAmpsPerMeterPerSecond: Double get() = value -val DerivativeGain.inAmpsPerInchPerSecond: Double +inline val DerivativeGain.inAmpsPerInchPerSecond: Double get() = inAmpsPerMeterPerSecond * METERS_PER_INCH -val DerivativeGain.inAmpsPerFootPerSecond: Double +inline val DerivativeGain.inAmpsPerFootPerSecond: Double get() = inAmpsPerMeterPerSecond * METERS_PER_FOOT -val DerivativeGain.inAmpsPerRadianPerSecond: Double +inline val DerivativeGain.inAmpsPerRadianPerSecond: Double get() = value -val DerivativeGain.inAmpsPerDegreePerSecond: Double +inline val DerivativeGain.inAmpsPerDegreePerSecond: Double get() = inAmpsPerRadianPerSecond * RADIANS_PER_DEGREES -val DerivativeGain.inAmpsPerRotationsPerMinute: Double +inline val DerivativeGain.inAmpsPerRotationsPerMinute: Double get() = inAmpsPerRadianPerSecond * SECONDS_PER_MINUTE * RADIANS_PER_ROTATION diff --git a/src/main/kotlin/org/team4099/lib/units/derived/ElectricalPotential.kt b/src/main/kotlin/org/team4099/lib/units/derived/ElectricalPotential.kt index 80ecfe3..b1843d9 100644 --- a/src/main/kotlin/org/team4099/lib/units/derived/ElectricalPotential.kt +++ b/src/main/kotlin/org/team4099/lib/units/derived/ElectricalPotential.kt @@ -9,14 +9,14 @@ typealias Volt = Fraction typealias ElectricalPotential = Value -val Double.volts +inline val Double.volts get() = ElectricalPotential(this) -val Number.volts +inline val Number.volts get() = toDouble().volts -val ElectricalPotential.inVolts +inline val ElectricalPotential.inVolts get() = value -val ElectricalPotential.inPercentOutput +inline val ElectricalPotential.inPercentOutput get() = this / BATTERY_VOLTAGE diff --git a/src/main/kotlin/org/team4099/lib/units/derived/Energy.kt b/src/main/kotlin/org/team4099/lib/units/derived/Energy.kt index f6ac9c4..0c72c18 100644 --- a/src/main/kotlin/org/team4099/lib/units/derived/Energy.kt +++ b/src/main/kotlin/org/team4099/lib/units/derived/Energy.kt @@ -32,71 +32,71 @@ typealias Joule = Fraction>, Squared> typealias Energy = Value -val Double.joules +inline val Double.joules get() = Energy(this) -val Number.joules +inline val Number.joules get() = Energy(this.toDouble()) -val Energy.inJoules: Double +inline val Energy.inJoules: Double get() = value -val Energy.inYottajoules: Double +inline val Energy.inYottajoules: Double get() = value * 1.yottainverse -val Energy.inZetajoules: Double +inline val Energy.inZetajoules: Double get() = value * 1.zetainverse -val Energy.inExajoules: Double +inline val Energy.inExajoules: Double get() = value * 1.exainverse -val Energy.inPetajoules: Double +inline val Energy.inPetajoules: Double get() = value * 1.petainverse -val Energy.inTerajoules: Double +inline val Energy.inTerajoules: Double get() = value * 1.terainverse -val Energy.inGigajoules: Double +inline val Energy.inGigajoules: Double get() = value * 1.gigainverse -val Energy.inMegajoules: Double +inline val Energy.inMegajoules: Double get() = value * 1.megainverse -val Energy.inKilojoules: Double +inline val Energy.inKilojoules: Double get() = value * 1.kiloinverse -val Energy.inHectojoules: Double +inline val Energy.inHectojoules: Double get() = value * 1.hectoinverse -val Energy.inDecajoules: Double +inline val Energy.inDecajoules: Double get() = value * 1.decainverse -val Energy.inDecijoules: Double +inline val Energy.inDecijoules: Double get() = value * 1.deciinverse -val Energy.inCentijoules: Double +inline val Energy.inCentijoules: Double get() = value * 1.centiinverse -val Energy.inMillijoules: Double +inline val Energy.inMillijoules: Double get() = value * 1.milliinverse -val Energy.inMicrojoules: Double +inline val Energy.inMicrojoules: Double get() = value * 1.microinverse -val Energy.inNanojoules: Double +inline val Energy.inNanojoules: Double get() = value * 1.nanoinverse -val Energy.inPicojoules: Double +inline val Energy.inPicojoules: Double get() = value * 1.picoinverse -val Energy.inFemtojoules: Double +inline val Energy.inFemtojoules: Double get() = value * 1.femtoinverse -val Energy.inAttojoules: Double +inline val Energy.inAttojoules: Double get() = value * 1.attoinverse -val Energy.inZeptojoules: Double +inline val Energy.inZeptojoules: Double get() = value * 1.zeptoinverse -val Energy.inYoctojoules: Double +inline val Energy.inYoctojoules: Double get() = value * 1.yoctoinverse diff --git a/src/main/kotlin/org/team4099/lib/units/derived/Force.kt b/src/main/kotlin/org/team4099/lib/units/derived/Force.kt index ec81efb..f218677 100644 --- a/src/main/kotlin/org/team4099/lib/units/derived/Force.kt +++ b/src/main/kotlin/org/team4099/lib/units/derived/Force.kt @@ -32,71 +32,71 @@ typealias Newton = Fraction, Squared> typealias Force = Value -val Double.newtons +inline val Double.newtons get() = Force(this) -val Number.newtons +inline val Number.newtons get() = Force(this.toDouble()) -val Force.inNewtons: Double +inline val Force.inNewtons: Double get() = value -val Force.inYottanewtons: Double +inline val Force.inYottanewtons: Double get() = value * 1.yottainverse -val Force.inZetanewtons: Double +inline val Force.inZetanewtons: Double get() = value * 1.zetainverse -val Force.inExanewtons: Double +inline val Force.inExanewtons: Double get() = value * 1.exainverse -val Force.inPetanewtons: Double +inline val Force.inPetanewtons: Double get() = value * 1.petainverse -val Force.inTeranewtons: Double +inline val Force.inTeranewtons: Double get() = value * 1.terainverse -val Force.inGiganewtons: Double +inline val Force.inGiganewtons: Double get() = value * 1.gigainverse -val Force.inMeganewtons: Double +inline val Force.inMeganewtons: Double get() = value * 1.megainverse -val Force.inKilonewtons: Double +inline val Force.inKilonewtons: Double get() = value * 1.kiloinverse -val Force.inHectonewtons: Double +inline val Force.inHectonewtons: Double get() = value * 1.hectoinverse -val Force.inDecanewtons: Double +inline val Force.inDecanewtons: Double get() = value * 1.decainverse -val Force.inDecinewtons: Double +inline val Force.inDecinewtons: Double get() = value * 1.deciinverse -val Force.inCentinewtons: Double +inline val Force.inCentinewtons: Double get() = value * 1.centiinverse -val Force.inMillinewtons: Double +inline val Force.inMillinewtons: Double get() = value * 1.milliinverse -val Force.inMicronewtons: Double +inline val Force.inMicronewtons: Double get() = value * 1.microinverse -val Force.inNanonewtons: Double +inline val Force.inNanonewtons: Double get() = value * 1.nanoinverse -val Force.inPiconewtons: Double +inline val Force.inPiconewtons: Double get() = value * 1.picoinverse -val Force.inFemtonewtons: Double +inline val Force.inFemtonewtons: Double get() = value * 1.femtoinverse -val Force.inAttonewtons: Double +inline val Force.inAttonewtons: Double get() = value * 1.attoinverse -val Force.inZeptonewtons: Double +inline val Force.inZeptonewtons: Double get() = value * 1.zeptoinverse -val Force.inYoctonewtons: Double +inline val Force.inYoctonewtons: Double get() = value * 1.yoctoinverse