summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2009-11-16 11:48:01 +0000
committerJakob Odersky <jodersky@gmail.com>2009-11-16 11:48:01 +0000
commitfbdf90f0deb14ddd8a457ff1f5f7715e4d3c2f2a (patch)
tree1840153eb5b273fdb1dbe585afde893c9b8d766f /src
parent9d20024aa35cd7f923ebfc1ed9a2ffbf2731da70 (diff)
downloadsims-fbdf90f0deb14ddd8a457ff1f5f7715e4d3c2f2a.tar.gz
sims-fbdf90f0deb14ddd8a457ff1f5f7715e4d3c2f2a.tar.bz2
sims-fbdf90f0deb14ddd8a457ff1f5f7715e4d3c2f2a.zip
Added new test.
Diffstat (limited to 'src')
-rw-r--r--src/graphyx/Graphyx.scala1
-rw-r--r--src/graphyx/tests/Carriage.scala55
-rw-r--r--src/graphyx/tests/EmptyTest.scala1
-rw-r--r--src/sims/collision/Collision.scala1
4 files changed, 56 insertions, 2 deletions
diff --git a/src/graphyx/Graphyx.scala b/src/graphyx/Graphyx.scala
index cfd67c6..81a8ee8 100644
--- a/src/graphyx/Graphyx.scala
+++ b/src/graphyx/Graphyx.scala
@@ -27,6 +27,7 @@ object Graphyx{
Friction2,
Restitution,
RagdollTest,
+ Carriage,
General1,
General2,
EmptyTest
diff --git a/src/graphyx/tests/Carriage.scala b/src/graphyx/tests/Carriage.scala
new file mode 100644
index 0000000..967c6e5
--- /dev/null
+++ b/src/graphyx/tests/Carriage.scala
@@ -0,0 +1,55 @@
+/*
+ * Graphyx
+ * copyright (c) 2009 Jakob Odersky
+ * made available under the MIT License
+*/
+
+package graphyx.tests
+
+import sims.dynamics._
+import sims.dynamics.joints._
+import sims.geometry._
+
+object Carriage extends Test{
+ val title = "Carriage"
+ val world = new World
+
+ def init = {
+ val car = new Car
+
+ val groundShapes = for (i <- (0 to 200).toList) yield (new Rectangle(0.2, 0.1, 1) {
+ pos = Vector2D(0.4 * i, 0)
+ transientShapes += car.chassis.shapes(0)
+ })
+ val ground = new Body(groundShapes: _*) //Rectangle(100, 0.1, 1).asBody
+ ground.pos = Vector2D(0,0)
+ ground.fixed = true
+ ground.rotation = -0.2
+
+
+ world += ground
+ world += car
+
+ }
+
+ class Car extends sims.prefabs.Prefab {
+
+ val chassis = (new Rectangle(0.5, 0.05, 10) {pos = Vector2D(0, 1)}).asBody
+ val rightWheel = (new Circle(0.1, 10) {pos = Vector2D(0.4,0.8)}).asBody
+ val leftWheel = (new Circle(0.1, 10) {pos = Vector2D(-0.4,0.8)}).asBody
+
+ override val bodies = List(chassis, rightWheel, leftWheel)
+
+ val rightStabelizer = new DistanceJoint(chassis, rightWheel)
+ val rightDamper = new SpringJoint(chassis, chassis.pos + Vector2D(rightWheel.pos.x, 0),
+ rightWheel, rightWheel.pos, 500) {damping = 1}
+
+ val leftStabelizer = new DistanceJoint(chassis, leftWheel)
+ val leftDamper = new SpringJoint(chassis, chassis.pos + Vector2D(leftWheel.pos.x, 0),
+ leftWheel, leftWheel.pos, 500) {damping = 1}
+
+ override val joints = List(rightStabelizer, rightDamper, leftStabelizer, leftDamper)
+
+ }
+
+}
diff --git a/src/graphyx/tests/EmptyTest.scala b/src/graphyx/tests/EmptyTest.scala
index bbca800..585a053 100644
--- a/src/graphyx/tests/EmptyTest.scala
+++ b/src/graphyx/tests/EmptyTest.scala
@@ -11,5 +11,4 @@ object EmptyTest extends Test{
override val title = "Empty Test"
val world = new World
def init = {}
-
}
diff --git a/src/sims/collision/Collision.scala b/src/sims/collision/Collision.scala
index ad23f4d..d674b30 100644
--- a/src/sims/collision/Collision.scala
+++ b/src/sims/collision/Collision.scala
@@ -69,7 +69,6 @@ abstract class Collision extends Constraint {
val cr2 = r2 cross tangent
val invMass = 1/b1.mass * (tangent dot tangent) + 1/b1.I * cr1 * cr1 + 1/b2.mass * (tangent dot tangent) + 1/b2.I * cr2 * cr2
val m = if (invMass == 0.0) 0.0 else 1/invMass
- val mu = shape1.friction * shape2.friction
val lambda = -m * Cdot
val cf = shape1.friction * shape2.friction
val cl = Math.min(Math.max(-normalForce * cf * h, lambda), normalForce * cf * h)