-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add inertial units + squared, cubed, and inverse properties of values
- Loading branch information
Showing
6 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Kilogram, Squared<Meter>> | ||
|
||
typealias MomentOfInertia = Value<Inertia> | ||
|
||
inline val Double.momentOfInertia | ||
get() = MomentOfInertia(this) | ||
|
||
inline val Number.momentOfInertia | ||
get() = MomentOfInertia(this.toDouble()) | ||
|
||
inline val MomentOfInertia.asKilogramsPerMeterSquared | ||
get() = value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} |