summaryrefslogtreecommitdiff
path: root/src/graphyx/tests/Joints2.scala
diff options
context:
space:
mode:
authorJakob Odersky <jodersky@gmail.com>2009-11-05 21:02:40 +0000
committerJakob Odersky <jodersky@gmail.com>2009-11-05 21:02:40 +0000
commit9d20024aa35cd7f923ebfc1ed9a2ffbf2731da70 (patch)
tree4e97fadc391b310ee1cc7156fda590dff414b2c3 /src/graphyx/tests/Joints2.scala
parent034bc5930ea6f01745f64a6070711d899d2c27ae (diff)
downloadsims-9d20024aa35cd7f923ebfc1ed9a2ffbf2731da70.tar.gz
sims-9d20024aa35cd7f923ebfc1ed9a2ffbf2731da70.tar.bz2
sims-9d20024aa35cd7f923ebfc1ed9a2ffbf2731da70.zip
Initial import.
Diffstat (limited to 'src/graphyx/tests/Joints2.scala')
-rw-r--r--src/graphyx/tests/Joints2.scala29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/graphyx/tests/Joints2.scala b/src/graphyx/tests/Joints2.scala
new file mode 100644
index 0000000..9ff5df3
--- /dev/null
+++ b/src/graphyx/tests/Joints2.scala
@@ -0,0 +1,29 @@
+/*
+ * 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._
+import sims.util._
+import sims.util.Positioning._
+
+object Joints2 extends Test{
+ override val title = "Joints2"
+ val world = new World
+ def init() = {
+ val length = 100
+ val distance = 0.2
+ val anchors = for (i <- (0 until length).toList) yield new Body(new Circle(0.03,1) {pos = Vector2D(i * distance,5)}) {fixed = true}
+ val balls = for (i <- (0 until length).toList) yield new Body(new Circle(0.1,1) {pos = Vector2D(i * distance,0); restitution = 1})
+ balls(0).pos = Vector2D(0, 5) + Polar(5, -Math.Pi / 1.5).toCarthesian
+ val joints = for (i <- (0 until length).toList) yield new DistanceJoint(anchors(i), balls(i))
+ for (a <- anchors) world += a
+ for (b <- balls) world += b
+ for (j <- joints) world += j
+ }
+}