Skip to content

Commit b11d717

Browse files
committedNov 1, 2019
Highlight weakness in accelerating a stopped Spatial
We need to know/compare against their *desired* direction, even if they are currently sitting still.
1 parent 07d2974 commit b11d717

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed
 

‎src/main/scala/com/billding/SampleSceneCreation.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class SampleSceneCreation(endingSpatial: Spatial) {
8989
Seconds(300),
9090
List(
9191
simplerVehicle(120, 0.1),
92-
simplerVehicle(60, 100),
92+
simplerVehicle(60, 10),
9393
)
9494
)
9595
)

‎src/main/scala/com/billding/physics/Spatial.scala

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package com.billding.physics
22

33
import com.billding.Orientation
4+
import squants.motion
45
import squants.motion.{Distance, DistanceUnit, MetersPerSecond, MetersPerSecondSquared, VelocityUnit}
56
import squants.space.{LengthUnit, Meters}
6-
import squants.{Acceleration, Length, QuantityVector, Time, UnitOfMeasure, Velocity}
7+
import squants.{Acceleration, Length, QuantityVector, Time, UnitOfMeasure, Velocity, motion}
8+
9+
import scala.language.postfixOps
710

811
case class Spatial(
912
r: QuantityVector[Distance],
@@ -90,6 +93,7 @@ object Spatial {
9093
dt: Time,
9194
dV: Acceleration,
9295
destination: Spatial): Spatial = {
96+
if (spatial.v.magnitude == MetersPerSecond(0)) throw new IllegalArgumentException("spatial needs to be moving")
9397
val unitVec =
9498
spatial
9599
.vectorTo(destination)

0 commit comments

Comments
 (0)
Please sign in to comment.