Skip to content

Commit 79508da

Browse files
committed
improve inertia
1 parent 7c5e9c8 commit 79508da

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

pga3dPhysics/src/main/scala/com/github/kright/pga3dphysics/Pga3dInertia.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,15 @@ class Pga3dInertia(val localToGlobal: Pga3dMotor,
4141
val localB = localToGlobal.reverseSandwich(globalB)
4242
localInertia.getKineticEnergy(localB)
4343

44-
def toSummable: Pga3dInertiaSummable =
44+
override def toSummable: Pga3dInertiaSummable =
4545
localToGlobal.sandwich(localInertia.toSummable)
46-
47-
def toPrecomputed: Pga3dInertiaPrecomputed =
46+
47+
override def toPrecomputed: Pga3dInertiaPrecomputed =
4848
Pga3dInertiaPrecomputed(localToGlobal, localInertia)
4949

50+
override def toInertia: Pga3dInertia =
51+
this
52+
5053
override def toString: String =
5154
s"Pga3dInertia(motor = $localToGlobal, inertia = $localInertia)"
5255

pga3dPhysics/src/main/scala/com/github/kright/pga3dphysics/Pga3dInertiaAbstract.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,9 @@ trait Pga3dInertiaAbstract:
1818

1919
def getKineticEnergy(velocity: Pga3dBivector): Double =
2020
(velocity v apply(velocity)) * 0.5
21+
22+
def toInertia: Pga3dInertia
23+
24+
def toSummable: Pga3dInertiaSummable
25+
26+
def toPrecomputed: Pga3dInertiaPrecomputed

pga3dPhysics/src/main/scala/com/github/kright/pga3dphysics/Pga3dInertiaLocal.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ final case class Pga3dInertiaLocal(mass: Double,
4747
yz = (localForque.wx + localB.xy * localB.xz * mrxy - localB.xy * localB.xz * mrxz) / mryz,
4848
)
4949

50-
def toSummable: Pga3dInertiaSummable =
50+
override def toSummable: Pga3dInertiaSummable =
5151
val mrxyz2 = (mrxy + mrxz + mryz) * 0.5
5252

5353
val mrx2 = mrxyz2 - mryz
@@ -67,9 +67,12 @@ final case class Pga3dInertiaLocal(mass: Double,
6767
yz = 0.0,
6868
)
6969

70-
def toInertia: Pga3dInertia =
70+
override def toInertia: Pga3dInertia =
7171
Pga3dInertia(Pga3dMotor.id, this)
7272

73+
override def toPrecomputed: Pga3dInertiaPrecomputed =
74+
Pga3dInertiaPrecomputed(Pga3dMotor.id, this)
75+
7376

7477
object Pga3dInertiaLocal:
7578

pga3dPhysics/src/main/scala/com/github/kright/pga3dphysics/Pga3dInertiaPrecomputed.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ class Pga3dInertiaPrecomputed(val localToGlobal: Pga3dMotor,
3030
override def invert(globalInertia: Pga3dBivector): Pga3dBivector =
3131
Pga3dMatrix.multiply(matrixInv, globalInertia)
3232

33-
def toInertia: Pga3dInertia =
33+
override def toInertia: Pga3dInertia =
3434
Pga3dInertia(localToGlobal, localInertia)
3535

36-
def toSummable: Pga3dInertiaSummable =
36+
override def toSummable: Pga3dInertiaSummable =
3737
toInertia.toSummable
38-
38+
39+
override def toPrecomputed: Pga3dInertiaPrecomputed =
40+
this

0 commit comments

Comments
 (0)