diff options
author | Jakob Odersky <jodersky@gmail.com> | 2009-11-28 20:25:35 +0000 |
---|---|---|
committer | Jakob Odersky <jodersky@gmail.com> | 2009-11-28 20:25:35 +0000 |
commit | 5031df4b26afd515274b5ca34f0d5380a99e4223 (patch) | |
tree | 41aac12ec2c03426910de72486a2d87e58cebc44 /src/graphyx/tests/Spring.scala | |
parent | fbdf90f0deb14ddd8a457ff1f5f7715e4d3c2f2a (diff) | |
download | sims-5031df4b26afd515274b5ca34f0d5380a99e4223.tar.gz sims-5031df4b26afd515274b5ca34f0d5380a99e4223.tar.bz2 sims-5031df4b26afd515274b5ca34f0d5380a99e4223.zip |
Minor graphyx modifications. Added tests. Added 'PrismaticJoint' (still incomplete). Started to transfer 'ForceJoints' to ordinary joints who use only constraints for correction. Started to add materials.
Diffstat (limited to 'src/graphyx/tests/Spring.scala')
-rw-r--r-- | src/graphyx/tests/Spring.scala | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/graphyx/tests/Spring.scala b/src/graphyx/tests/Spring.scala new file mode 100644 index 0000000..4eec8de --- /dev/null +++ b/src/graphyx/tests/Spring.scala @@ -0,0 +1,32 @@ +package graphyx.tests + +import sims.dynamics._ +import sims.dynamics.joints._ +import sims.geometry._ +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)) + } + } + + 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) + + world += anchor + world += particle + world += spring + } +} |