diff options
Diffstat (limited to 'src')
33 files changed, 151 insertions, 68 deletions
diff --git a/src/graphyx/Graphyx.scala b/src/graphyx/Graphyx.scala index 01caea8..192b897 100644 --- a/src/graphyx/Graphyx.scala +++ b/src/graphyx/Graphyx.scala @@ -22,10 +22,10 @@ object Graphyx{ Atom, Chain, Wave, + Net, Stacking, BallStack, Cup, - Net, Friction, Friction2, Restitution, @@ -33,6 +33,7 @@ object Graphyx{ Carriage, General1, General2, + Cannon, EmptyTest ) @@ -48,10 +49,10 @@ object Graphyx{ val physicsActor = new PhysicsActor val guiActor = new GUIActor - + def main(args: Array[String]): Unit = { test.init() - physicsActor.world = test.world + physicsActor.world = test.world guiActor.start() physicsActor.start() } diff --git a/src/graphyx/actors/GUIActor.scala b/src/graphyx/actors/GUIActor.scala index a704f6a..0116551 100644 --- a/src/graphyx/actors/GUIActor.scala +++ b/src/graphyx/actors/GUIActor.scala @@ -7,11 +7,10 @@ package graphyx.actors import graphyx.graphics._ -import graphyx.gui._ import scala.actors._ class GUIActor extends Actor{ - val container = new Container + val container = new graphyx.gui.Container var continue = true diff --git a/src/graphyx/actors/PhysicsActor.scala b/src/graphyx/actors/PhysicsActor.scala index b93541f..0bc7faf 100644 --- a/src/graphyx/actors/PhysicsActor.scala +++ b/src/graphyx/actors/PhysicsActor.scala @@ -6,6 +6,7 @@ package graphyx.actors +import graphyx._ import graphyx.graphics._ import sims.dynamics._ import scala.actors._ @@ -30,8 +31,9 @@ class PhysicsActor extends Actor{ Graphyx.guiActor ! new Scene(world) {override val fps = _fps} - while (mailboxSize > 0) { - receive { + receiveWithin(0) { + case TIMEOUT => () + case Stop => { simulate = false println("Simulation stopped.") @@ -49,7 +51,6 @@ class PhysicsActor extends Actor{ case other => println("Engine received unknown command: '" + other + "'") } - } val h = (System.nanoTime - t0) / 1000000 val f = 60 diff --git a/src/graphyx/graphics/Drawable.scala b/src/graphyx/graphics/Drawable.scala index fefd97d..07f3491 100644 --- a/src/graphyx/graphics/Drawable.scala +++ b/src/graphyx/graphics/Drawable.scala @@ -13,7 +13,7 @@ import sims.geometry._ trait Drawable { /**Java Graphics Objekt zur graphischen Darstellung*/ - var g: java.awt.Graphics = _ + var g: java.awt.Graphics2D = _ /**Anzahl von Pixeln pro Meter.*/ var ppm: Double = 39.37007874015748 * 96 //ppm = i/m * p/i diff --git a/src/graphyx/graphics/GraphicalRectangle.scala b/src/graphyx/graphics/GraphicalRectangle.scala index d3774bb..ae65c5e 100644 --- a/src/graphyx/graphics/GraphicalRectangle.scala +++ b/src/graphyx/graphics/GraphicalRectangle.scala @@ -15,4 +15,4 @@ case class GraphicalRectangle(real: Rectangle) extends Rectangle(real.halfWidth, g.setColor(java.awt.Color.BLACK) drawPolygon(vertices) } -} +}
\ No newline at end of file diff --git a/src/graphyx/graphics/GraphicalRegularPolygon.scala b/src/graphyx/graphics/GraphicalRegularPolygon.scala index 919b857..a3906c3 100644 --- a/src/graphyx/graphics/GraphicalRegularPolygon.scala +++ b/src/graphyx/graphics/GraphicalRegularPolygon.scala @@ -16,5 +16,4 @@ case class GraphicalRegularPolygon(real: RegularPolygon) extends RegularPolygon( g.setColor(java.awt.Color.BLACK) drawPolygon(vertices) } - -} +}
\ No newline at end of file diff --git a/src/graphyx/graphics/GraphicalWorld.scala b/src/graphyx/graphics/GraphicalWorld.scala index 2837d69..abc9cbb 100644 --- a/src/graphyx/graphics/GraphicalWorld.scala +++ b/src/graphyx/graphics/GraphicalWorld.scala @@ -13,7 +13,16 @@ case class GraphicalWorld(real: World){ val iterations = real.iterations val overCWarning = real.overCWarning val gravity = real.gravity - val monitorResults = for (b <- real.bodies; m <- real.monitors; if (b.monitor)) yield "b" + b.uid.toString + " " + m._1 + ": " + m._2(b) + val monitorResults = for (m <- real.monitors) yield + new MonitorResult(m, + for (b <- real.bodies.toList; if (b.monitor)) yield (b.uid, m._1, m._2(b)) + ) + val monitorFlatResults = for (b <- real.bodies; m <- real.monitors; if (b.monitor)) yield (b.uid, m._1, m._2(b)) val enableCollisionDetection = real.enableCollisionDetection val enablePositionCorrection = real.enablePositionCorrection } + +class MonitorResult ( + val monitor: (String, Body => Any), + val results: List[(Int, String, Any)] +) diff --git a/src/graphyx/gui/AboutHelpFrame.scala b/src/graphyx/gui/AboutHelpFrame.scala index 4dba9f1..52bfb73 100644 --- a/src/graphyx/gui/AboutHelpFrame.scala +++ b/src/graphyx/gui/AboutHelpFrame.scala @@ -9,11 +9,13 @@ class AboutHelpFrame extends Frame { title = "About" contents = new TextArea( """|Graphyx, testing and visualization tool for SiMS. - | + | |copyright (c) 2009 Jakob Odersky |SiMS and Graphyx are made available under the MIT License | - |http://sourceforge.net/projects/simplemechanics/""".stripMargin + |http://sourceforge.net/projects/simplemechanics/ + | + |Version 1.1""".stripMargin ) {editable = false} } diff --git a/src/graphyx/gui/Container.scala b/src/graphyx/gui/Container.scala index 5181df7..80886f8 100644 --- a/src/graphyx/gui/Container.scala +++ b/src/graphyx/gui/Container.scala @@ -6,12 +6,14 @@ package graphyx.gui -import graphyx.graphics._ import sims.dynamics._ - +import graphyx.graphics._ +import java.io._ class Container { val mainFrame = new MainFrame(this) + //val plotFrames = new ArrayBuffer[plot.PlotFrame[Body]] + var scene: Scene = Scene(new World) def show() = { @@ -20,6 +22,7 @@ class Container { def update(s: Scene) = { scene = s + mainFrame.mainPanel.controlPanel.update() mainFrame.mainPanel.worldPanel.update() mainFrame.mainPanel.infoPanel.update() mainFrame.mainPanel.optionsPanel.update() @@ -29,5 +32,6 @@ class Container { def exitGUI() = { mainFrame.dispose AboutHelpFrame.frame.dispose + //plotFrames.foreach(_.dispose) } } diff --git a/src/graphyx/gui/ControlPanel.scala b/src/graphyx/gui/ControlPanel.scala index 2708d54..2cde7e6 100644 --- a/src/graphyx/gui/ControlPanel.scala +++ b/src/graphyx/gui/ControlPanel.scala @@ -6,6 +6,7 @@ package graphyx.gui +import graphyx._ import graphyx.actors._ import graphyx.gui._ import scala.swing._ @@ -33,4 +34,7 @@ class ControlPanel(container: Container) extends BoxPanel(Orientation.Horizontal case SelectionChanged(`cboTest`) => Graphyx.test = Graphyx.tests(cboTest.selection.index) } + def update() { + btnFire.enabled = Graphyx.test.enableEvent + } } diff --git a/src/graphyx/gui/InfoPanel.scala b/src/graphyx/gui/InfoPanel.scala index 484f3d7..6e58ba3 100644 --- a/src/graphyx/gui/InfoPanel.scala +++ b/src/graphyx/gui/InfoPanel.scala @@ -23,6 +23,6 @@ class InfoPanel(container: Container) extends BoxPanel(Orientation.Vertical){ out.text += "Warning: some bodies passed the speed of light! Simulation may be highly incorrect.\n" } else out.foreground = java.awt.Color.black - for (r <- container.scene.world.monitorResults) out.text += r + "\n" + for (r <- container.scene.world.monitorFlatResults) out.text += "b" + r._1 + " " + r._2 + ": " + r._3 + "\n" } } diff --git a/src/graphyx/gui/MainFrame.scala b/src/graphyx/gui/MainFrame.scala index 89812a5..6b1f2fe 100644 --- a/src/graphyx/gui/MainFrame.scala +++ b/src/graphyx/gui/MainFrame.scala @@ -6,6 +6,7 @@ package graphyx.gui +import graphyx._ import sims._ import scala.swing._ diff --git a/src/graphyx/gui/WorldPanel.scala b/src/graphyx/gui/WorldPanel.scala index cd91f00..7f9fbee 100644 --- a/src/graphyx/gui/WorldPanel.scala +++ b/src/graphyx/gui/WorldPanel.scala @@ -11,6 +11,8 @@ import sims.geometry._ import sims.dynamics._ import scala.swing._ import scala.swing.event._ +import scala.collection.mutable.Map +import scala.collection.mutable.Queue class WorldPanel(container: Container) extends BoxPanel(Orientation.Vertical){ cursor = new java.awt.Cursor(java.awt.Cursor.CROSSHAIR_CURSOR) @@ -44,8 +46,8 @@ class WorldPanel(container: Container) extends BoxPanel(Orientation.Vertical){ var drawCollisions = false var trace = false - override def paintComponent(g: java.awt.Graphics) = { - var parts: Seq[graphyx.graphics.Drawable] = Seq() + override def paintComponent(g: java.awt.Graphics2D) = { + var parts: Seq[Drawable] = Seq() if (drawShapes) parts ++= scene.shapes if (drawJoints) parts ++= scene.joints if (drawAABBs) parts ++= scene.aabbs @@ -60,7 +62,7 @@ class WorldPanel(container: Container) extends BoxPanel(Orientation.Vertical){ g.translate(-offset.x.toInt, offset.y.toInt) } - def drawAxes(g: java.awt.Graphics): Unit = { + def drawAxes(g: java.awt.Graphics2D): Unit = { g.setColor(java.awt.Color.GRAY) g.drawLine(0, size.height - offset.y.toInt, size.width, size.height - offset.y.toInt) g.drawLine(offset.x.toInt, 0, offset.x.toInt, size.height) @@ -72,7 +74,7 @@ class WorldPanel(container: Container) extends BoxPanel(Orientation.Vertical){ */ } - def drawParts(parts: Iterable[graphics.Drawable], g: java.awt.Graphics) = { + def drawParts(parts: Iterable[Drawable], g: java.awt.Graphics2D) = { for (p <- parts){ p.g = g p.windowHeight = super.size.height @@ -82,9 +84,8 @@ class WorldPanel(container: Container) extends BoxPanel(Orientation.Vertical){ } } - import collection.mutable._ - val prevPos: collection.mutable.Map[Int, collection.mutable.Queue[Vector2D]] = Map() - def trace(shapes: Iterable[graphics.GraphicalShape], g: java.awt.Graphics) = { + val prevPos: Map[Int, Queue[Vector2D]] = Map() + def trace(shapes: Iterable[GraphicalShape], g: java.awt.Graphics2D) = { for (s <- shapes) { s.g = g s.windowHeight = super.size.height diff --git a/src/graphyx/tests/Atom.scala b/src/graphyx/tests/Atom.scala index 84fe05c..31d03fc 100644 --- a/src/graphyx/tests/Atom.scala +++ b/src/graphyx/tests/Atom.scala @@ -22,6 +22,7 @@ object Atom extends Test{ connections = Nil } + enableEvent = true override def fireEvent = { val e = (new Circle(0.1, 10) {pos = Vector2D(0, -1)}).asBody e.linearVelocity = Vector2D(-50,100) diff --git a/src/graphyx/tests/Cannon.scala b/src/graphyx/tests/Cannon.scala new file mode 100644 index 0000000..7738103 --- /dev/null +++ b/src/graphyx/tests/Cannon.scala @@ -0,0 +1,59 @@ +package graphyx.tests + +import sims.dynamics._ +import sims.geometry._ +import sims.prefabs._ + +object Cannon extends Test{ + val title = "Cannon" + val world = new World + + def init = { + val cannon = new Prefab{ + val hull = new Body( + new Rectangle(0.1,0.5,1) {pos = Vector2D(0.1, 0.6); friction = 0.0}, + new Rectangle(0.1,0.5,1) {pos = Vector2D(0.5, 0.6); friction = 0.0}, + new Rectangle(0.1,0.1,1) {pos = Vector2D(0.3, 0.2); friction = 0.0} + ) + hull.fixed = true + hull.rotation -= Math.Pi / 2 + + val ball = new Body(new Circle(0.1,100) {pos = Vector2D(0.3, 0.56)}) + + override val bodies = List(hull, ball) + override val joints = Nil + } + val n = 10 + val r = 0.1 + val initialPos = Vector2D(5,0) + val stack = for (i <- (0 to n).toList) yield { + for (j <- (0 to n-i).toList) yield + new Body( + new Circle(r,10){ + pos = Vector2D(2 * j * r + i * r, 1.7 * i * r) + initialPos + } + ) {fixed = (i == 0)} + } + world += cannon + world ++= List.flatten(stack) + + } + + enableEvent = true + override def fireEvent() = blastBomb + + def blastBomb() = { + val bombPos = Vector2D(0, 0.56) + val bombRadius = 1 + val bombImpulse = 200 + val region = new Circle(bombRadius, 0) {pos = bombPos} + val detector = world.detector.asInstanceOf[sims.collision.GridDetector] + val collisions = for (s <- world.shapes; if detector.colliding(sims.collision.Pair(region, s))) yield detector.collision(sims.collision.Pair(region, s)) + for (c <- collisions) { + if (c.shape1 != region) + for(p <- c.points) c.shape1.body.applyImpulse((p - bombPos).unit * bombImpulse, p) + if (c.shape2 != region) + for(p <- c.points) c.shape2.body.applyImpulse((p - bombPos).unit * bombImpulse, p) + } + } +} diff --git a/src/graphyx/tests/EmptyTest.scala b/src/graphyx/tests/EmptyTest.scala index 585a053..0e3bd84 100644 --- a/src/graphyx/tests/EmptyTest.scala +++ b/src/graphyx/tests/EmptyTest.scala @@ -7,6 +7,7 @@ package graphyx.tests import sims.dynamics._ +import sims.geometry._ object EmptyTest extends Test{ override val title = "Empty Test" val world = new World diff --git a/src/graphyx/tests/Friction.scala b/src/graphyx/tests/Friction.scala index 268d054..ba9fb69 100644 --- a/src/graphyx/tests/Friction.scala +++ b/src/graphyx/tests/Friction.scala @@ -47,6 +47,7 @@ object Friction extends Test{ world += r3 } + enableEvent = true override def fireEvent = { world -= r1 world -= r2 diff --git a/src/graphyx/tests/Friction2.scala b/src/graphyx/tests/Friction2.scala index f6731e2..9d03bd9 100644 --- a/src/graphyx/tests/Friction2.scala +++ b/src/graphyx/tests/Friction2.scala @@ -20,10 +20,10 @@ object Friction2 extends Test{ friction = (i * 1.0 / 10) restitution = 0 }) - val ground = new Body(shapes: _*) //Rectangle(100, 0.1, 1).asBody + val ground = new Body(shapes: _*) ground.pos = Vector2D(0,0) ground.fixed = true - ground.rotation = -0.2 + ground.rotation = -Math.Pi / 5 world += ground val b: Body = (new Circle(0.1,10)) ~ (new Circle(0.1,10) {pos = Vector2D(0.2,0)}) ~ (new Circle(0.1,10) {pos = Vector2D(0.4,0)}) diff --git a/src/graphyx/tests/General1.scala b/src/graphyx/tests/General1.scala index 7d8703b..71e041b 100644 --- a/src/graphyx/tests/General1.scala +++ b/src/graphyx/tests/General1.scala @@ -106,6 +106,7 @@ object General1 extends Test{ world += (new Circle(0.1,1) {pos = Vector2D(2,2)}) ~ (new Circle(0.1,1) {pos = Vector2D(2,2.2)}) } + enableEvent = true override def fireEvent() = blastBomb def blastBomb() = { diff --git a/src/graphyx/tests/Spring.scala b/src/graphyx/tests/Spring.scala index 439259f..e7fecb8 100644 --- a/src/graphyx/tests/Spring.scala +++ b/src/graphyx/tests/Spring.scala @@ -7,23 +7,14 @@ import java.io._ object Spring extends Test{ val title = "Spring" - //val fout = new java.io.FileOutputStream("out.csv") - //val sout = new java.io.PrintStream(fout) - val world = new World { - override def postStep = { - //for (b <- bodies; if (b.monitor)) sout.println(monitors(0)._2(b)) - } - } + val world = new World def init = { val anchor = Circle(0.05, 10).asBody anchor.fixed = true - val particle = (new Circle(0.1, 10) {pos = Vector2D(0, -1)}).asBody - val spring = new SpringJoint(anchor, particle, 500, 0.6) - //val spring = new PrismaticJoint(anchor, particle) - spring.damping = 1 - particle.monitor = true - world.monitors += ("", _.pos.y.toString) + val particle = (new Circle(0.1, 20) {pos = Vector2D(0, -3)}).asBody + val spring = new SpringJoint(anchor, particle, 500, 2) + spring.damping = 0.5 world += anchor world += particle diff --git a/src/graphyx/tests/Test.scala b/src/graphyx/tests/Test.scala index b539283..ca0f8e8 100644 --- a/src/graphyx/tests/Test.scala +++ b/src/graphyx/tests/Test.scala @@ -11,6 +11,7 @@ trait Test { val world: World val title: String def init(): Unit + var enableEvent: Boolean = false def fireEvent(): Unit = println("No custom event method defined.") override def toString() = title } diff --git a/src/graphyx/tests/Wave.scala b/src/graphyx/tests/Wave.scala index 62ec194..d3359c1 100644 --- a/src/graphyx/tests/Wave.scala +++ b/src/graphyx/tests/Wave.scala @@ -11,17 +11,24 @@ object Wave extends Test{ def init = { val n = 50 - val anchors = for (i <- (0 to n).toList) yield (new Body(new Circle(0.01,1) {pos = Vector2D(0.4 * i, 5)}) {fixed = true}) - val particles = for (i <- (0 to n).toList) yield (new Body(new Circle(0.1,10) {pos = Vector2D(0.4 * i, 0)})) - val rails = (for (i <- (0 to n).toList) yield (new PrismaticJoint(anchors(i), particles(i)))) - val springs = (for (i <- (0 to n).toList) yield (new SpringJoint(anchors(i), particles(i), 5)))// {damping = 0.00})) - world ++= anchors - world ++= particles - for (j <- rails ++ springs) world += j - val lateralSprings = (for (i <- (0 to (n - 1)).toList) yield (new SpringJoint(particles(i), particles(i + 1), 50.0))) - for (j <- lateralSprings) world += j + val anchors = for (i <- (0 to n).toList) yield + new Body(new Circle(0.01,1) {pos = Vector2D(0.4 * i, 5)}) {fixed = true} + + val particles = for (i <- (0 to n).toList) yield + new Body(new Circle(0.1,10) {pos = Vector2D(0.4 * i, 0)}) + + val rails = for (i <- (0 to n).toList) yield + new PrismaticJoint(anchors(i), particles(i)) + + val springs = for (i <- (0 to n).toList) yield + new SpringJoint(anchors(i), particles(i), 5)// {damping = 0.00}) + val lateralSprings = for (i <- (0 to (n - 1)).toList) yield + new SpringJoint(particles(i), particles(i + 1), 50.0) + + world ++= anchors + world ++= particles + for (j <- rails ++ springs ++ lateralSprings) world += j } - } diff --git a/src/sims/collision/AABB.scala b/src/sims/collision/AABB.scala index ea696f2..f3a0b71 100644 --- a/src/sims/collision/AABB.scala +++ b/src/sims/collision/AABB.scala @@ -6,7 +6,7 @@ package sims.collision -import geometry._ +import sims.geometry._ /** * Axis Aligned Bounding Boxes (AABBs) are rectangles that frame a shape. diff --git a/src/sims/collision/CircleCollision.scala b/src/sims/collision/CircleCollision.scala index e77c8e2..04cf2d7 100644 --- a/src/sims/collision/CircleCollision.scala +++ b/src/sims/collision/CircleCollision.scala @@ -6,8 +6,8 @@ package sims.collision -import geometry._ -import dynamics._ +import sims.geometry._ +import sims.dynamics._ /**Collision between two circles.*/ case class CircleCollision(c1: Circle, c2: Circle) extends Collision { diff --git a/src/sims/collision/Collision.scala b/src/sims/collision/Collision.scala index ce09ac2..540081a 100644 --- a/src/sims/collision/Collision.scala +++ b/src/sims/collision/Collision.scala @@ -6,8 +6,8 @@ package sims.collision -import dynamics._ -import geometry._ +import sims.dynamics._ +import sims.geometry._ /**Collision between two shapes. Contains methods to compute the collision response.*/ abstract class Collision extends Constraint { diff --git a/src/sims/collision/Detector.scala b/src/sims/collision/Detector.scala index 0a3ad5b..96af5dc 100644 --- a/src/sims/collision/Detector.scala +++ b/src/sims/collision/Detector.scala @@ -9,8 +9,6 @@ package sims.collision import sims.geometry._ import sims.dynamics._ -import scala.collection._ -import scala.collection.mutable._ /**A world detects its collisions through concrete implementations of this class.*/ abstract class Detector { diff --git a/src/sims/collision/GridDetector.scala b/src/sims/collision/GridDetector.scala index f5ed99a..abc40f2 100644 --- a/src/sims/collision/GridDetector.scala +++ b/src/sims/collision/GridDetector.scala @@ -9,7 +9,8 @@ package sims.collision import sims.dynamics._ import sims.geometry._ import scala.collection._ -import scala.collection.mutable._ +import scala.collection.mutable.ArrayBuffer +import scala.collection.mutable.HashMap /**A conrete implementation of <code>Detector</code>. <code>GridDetector</code> divides the world into a grid * for faster collision detection.*/ diff --git a/src/sims/collision/PolyCollision.scala b/src/sims/collision/PolyCollision.scala index b4fa917..5296f41 100644 --- a/src/sims/collision/PolyCollision.scala +++ b/src/sims/collision/PolyCollision.scala @@ -9,7 +9,6 @@ package sims.collision import sims.geometry._ import sims.dynamics._ import scala.collection.mutable.Map -import scala.collection.mutable._ /**Collision between two convex polygons.*/ case class PolyCollision(p1: ConvexPolygon, p2: ConvexPolygon) extends Collision { diff --git a/src/sims/dynamics/World.scala b/src/sims/dynamics/World.scala index 0230a50..f24a3fd 100644 --- a/src/sims/dynamics/World.scala +++ b/src/sims/dynamics/World.scala @@ -9,7 +9,7 @@ package sims.dynamics import sims.geometry._ import sims.collision._ import sims.dynamics.joints._ -import scala.collection.mutable._ +import scala.collection.mutable.ArrayBuffer /**A world contains and simulates a system of rigid bodies and joints.*/ class World { @@ -35,7 +35,7 @@ class World { * Example usage: monitors += ("Y-Position", _.pos.y.toString) * This will calculate all bodies - whose <code>monitor</code> field is set to * <code>true</code> - second position components.*/ - val monitors = new ArrayBuffer[(String, Body => String)] + val monitors = new ArrayBuffer[(String, Body => Any)] /**Collsion detector who manages collision detection in this world.*/ val detector: Detector = new GridDetector(this) @@ -65,7 +65,7 @@ class World { def +=(joint: Joint): Unit = joints += joint /**Adds the given prefabricated system of bodies and joints to this world.*/ - def +=(p: prefabs.Prefab): Unit = { + def +=(p: sims.prefabs.Prefab): Unit = { for (b <- p.bodies) this += b for (j <- p.joints) this += j } @@ -80,7 +80,7 @@ class World { def -=(joint: Joint): Unit = joints -= joint /**Removes the given prefabricated system of bodies and joints from this world.*/ - def -=(p: prefabs.Prefab): Unit = { + def -=(p: sims.prefabs.Prefab): Unit = { for (b <- p.bodies) this -= b for (j <- p.joints) this -= j } @@ -113,12 +113,9 @@ class World { //integration of acclerations, yields velocities for (b <- bodies) { - val m = b.mass b.applyForce(gravity * b.mass) - val a = b.force / b.mass - val alpha = b.torque / b.I - b.linearVelocity = b.linearVelocity + a * timeStep - b.angularVelocity = b.angularVelocity + alpha * timeStep + b.linearVelocity = b.linearVelocity + (b.force / b.mass) * timeStep + b.angularVelocity = b.angularVelocity + (b.torque / b.I) * timeStep } //correction of velocities diff --git a/src/sims/dynamics/joints/DistanceJoint.scala b/src/sims/dynamics/joints/DistanceJoint.scala index efb49e5..1bf9b46 100644 --- a/src/sims/dynamics/joints/DistanceJoint.scala +++ b/src/sims/dynamics/joints/DistanceJoint.scala @@ -6,6 +6,7 @@ package sims.dynamics.joints +import sims.dynamics._ import sims.geometry._ /** DistanceJoints keep their connection points at a constant distance. diff --git a/src/sims/dynamics/joints/SpringJoint.scala b/src/sims/dynamics/joints/SpringJoint.scala index 1267ccf..4d44864 100644 --- a/src/sims/dynamics/joints/SpringJoint.scala +++ b/src/sims/dynamics/joints/SpringJoint.scala @@ -6,6 +6,7 @@ package sims.dynamics.joints +import sims.dynamics._ import sims.geometry._ /**A spring obeying Hooke's law. diff --git a/src/sims/dynamics/joints/test/PrismaticJoint.scala b/src/sims/dynamics/joints/test/PrismaticJoint.scala index d4b43b2..040647d 100644 --- a/src/sims/dynamics/joints/test/PrismaticJoint.scala +++ b/src/sims/dynamics/joints/test/PrismaticJoint.scala @@ -1,5 +1,7 @@ package sims.dynamics.joints.test +import sims.dynamics._ +import sims.dynamics.joints._ import sims.geometry._ case class PrismaticJoint(node1: Body, anchor1: Vector2D, node2: Body, anchor2: Vector2D) extends Joint{ diff --git a/src/sims/dynamics/joints/test/UnitCircleJoint.scala b/src/sims/dynamics/joints/test/UnitCircleJoint.scala index 64f613c..09e72d9 100644 --- a/src/sims/dynamics/joints/test/UnitCircleJoint.scala +++ b/src/sims/dynamics/joints/test/UnitCircleJoint.scala @@ -7,6 +7,7 @@ package sims.dynamics.joints.test import sims.dynamics._ +import sims.dynamics.joints._ import sims.geometry._ class UnitCircleJoint(body: Body, anchor: Vector2D) extends Joint{ |