diff --git a/build.gradle b/build.gradle index 3a51b68..829ef2b 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,7 @@ publishing { release(MavenPublication) { groupId = 'org.team4099' artifactId = 'falconutils' - version = '1.1.7' + version = '1.1.8' from(components["kotlin"]) } diff --git a/src/main/kotlin/org/team4099/lib/controller/ArmFeedforward.kt b/src/main/kotlin/org/team4099/lib/controller/ArmFeedforward.kt index 60a2043..585d296 100644 --- a/src/main/kotlin/org/team4099/lib/controller/ArmFeedforward.kt +++ b/src/main/kotlin/org/team4099/lib/controller/ArmFeedforward.kt @@ -12,7 +12,6 @@ import org.team4099.lib.units.derived.VelocityFeedforward import org.team4099.lib.units.derived.Volt import org.team4099.lib.units.derived.inRadians import org.team4099.lib.units.derived.inVolts -import org.team4099.lib.units.derived.inVoltsPerRadian import org.team4099.lib.units.derived.inVoltsPerRadianPerSecond import org.team4099.lib.units.derived.inVoltsPerRadianPerSecondPerSecond import org.team4099.lib.units.derived.perRadianPerSecondPerSecond diff --git a/src/main/kotlin/org/team4099/lib/units/Value.kt b/src/main/kotlin/org/team4099/lib/units/Value.kt index 21d3627..14d49eb 100644 --- a/src/main/kotlin/org/team4099/lib/units/Value.kt +++ b/src/main/kotlin/org/team4099/lib/units/Value.kt @@ -11,6 +11,15 @@ value class Value(val value: Double) : Comparable> { inline val sign: Double get() = sign(value) + inline val inverse: Value> + get() = Value(1 / value) + + inline val squared: Value> + get() = Value(value * value) + + inline val cubed: Value> + get() = Value(value * value * value) + inline operator fun plus(o: Value): Value = Value(value + o.value) inline operator fun minus(o: Value): Value = Value(value - o.value) 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 9174608..7a162ab 100644 --- a/src/main/kotlin/org/team4099/lib/units/derived/Characterization.kt +++ b/src/main/kotlin/org/team4099/lib/units/derived/Characterization.kt @@ -3,7 +3,6 @@ package org.team4099.lib.units.derived import org.team4099.lib.units.Acceleration import org.team4099.lib.units.Fraction import org.team4099.lib.units.UnitKey -import org.team4099.lib.units.Unitless import org.team4099.lib.units.Value import org.team4099.lib.units.Velocity import org.team4099.lib.units.base.Ampere diff --git a/src/main/kotlin/org/team4099/lib/units/derived/Inertia.kt b/src/main/kotlin/org/team4099/lib/units/derived/Inertia.kt new file mode 100644 index 0000000..d8bfc0e --- /dev/null +++ b/src/main/kotlin/org/team4099/lib/units/derived/Inertia.kt @@ -0,0 +1,20 @@ +package org.team4099.lib.units.derived + +import org.team4099.lib.units.Product +import org.team4099.lib.units.Squared +import org.team4099.lib.units.Value +import org.team4099.lib.units.base.Kilogram +import org.team4099.lib.units.base.Meter + +typealias Inertia = Product> + +typealias MomentOfInertia = Value + +inline val Double.momentOfInertia + get() = MomentOfInertia(this) + +inline val Number.momentOfInertia + get() = MomentOfInertia(this.toDouble()) + +inline val MomentOfInertia.asKilogramsPerMeterSquared + get() = value diff --git a/src/test/kotlin/team4099/units/InertiaTest.kt b/src/test/kotlin/team4099/units/InertiaTest.kt new file mode 100644 index 0000000..53c0f1a --- /dev/null +++ b/src/test/kotlin/team4099/units/InertiaTest.kt @@ -0,0 +1,19 @@ +package team4099.units + +import org.junit.jupiter.api.Test +import org.team4099.lib.units.base.grams +import org.team4099.lib.units.base.inches +import org.team4099.lib.units.derived.MomentOfInertia +import org.team4099.lib.units.derived.asKilogramsPerMeterSquared +import org.team4099.lib.units.kilo + +class InertiaTest { + + private val kEpsilon = 1E-9 + + @Test + fun testInertia() { + val inertia: MomentOfInertia = 1.0.kilo.grams * 3.0.inches.squared + println(inertia.asKilogramsPerMeterSquared) + } +}