summaryrefslogtreecommitdiff
path: root/src/graphyx/tests/Wave.scala
blob: d3359c1155687a93499e4abf23628f3507a649a9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package graphyx.tests

import sims.dynamics._
import sims.dynamics.joints._
import sims.dynamics.joints.test._
import sims.geometry._

object Wave extends Test{
  val title = "Wave"
  val world = new World {gravity = Vector2D.Null}
  
  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})
    
    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   
  }
}