예제 #1
0
def theme1(world, viewport):
	# attach bodies to world
	n = 35
	# for i in xrange(n):
	# 	points = []
	# 	for j in xrange(3):
	# 		point = PhyPoint()
	# 		point.s = vec((rd(0, 10), rd(0, 10), rd(0, 10)))
	# 		point.mass = 2
	# 		#point.v = vec((rd(-1, 1), rd(-1, 1), rd(-1, 1)))
	# 
	# 		points.append(point)
	# 		world.attach(point)
	# 	body = PhyBody(points[0], points[1], points[2], ShapeSquare(1))
	# 	world.attach(body)
	for i in xrange(n):
		p = PhyPoint()
		p.s = vec((rd(0, 10), rd(0, 10), rd(0, 10)))
		p.v = vec((rd(-1, 1), rd(-1, 1), rd(-1, 1)))
		p.mass = 2
		world.attach(p)
	for i in xrange(1,n):
		p1 = world.points[i-1]
		p2 = world.points[i]
		world.attach(Spring(p1, p2, rd(5,8), 1))
		# world.attach(Stick(p1, p2, norm(p1.s-p2.s)))

	# world.attach(GravityField())
	world.attach(FField(f=0.35))
	viewport.s = (0, -40, 20)
예제 #2
0
def theme1(world, viewport):
    # attach bodies to world
    n = 35
    # for i in xrange(n):
    # 	points = []
    # 	for j in xrange(3):
    # 		point = PhyPoint()
    # 		point.s = vec((rd(0, 10), rd(0, 10), rd(0, 10)))
    # 		point.mass = 2
    # 		#point.v = vec((rd(-1, 1), rd(-1, 1), rd(-1, 1)))
    #
    # 		points.append(point)
    # 		world.attach(point)
    # 	body = PhyBody(points[0], points[1], points[2], ShapeSquare(1))
    # 	world.attach(body)
    for i in xrange(n):
        p = PhyPoint()
        p.s = vec((rd(0, 10), rd(0, 10), rd(0, 10)))
        p.v = vec((rd(-1, 1), rd(-1, 1), rd(-1, 1)))
        p.mass = 2
        world.attach(p)
    for i in xrange(1, n):
        p1 = world.points[i - 1]
        p2 = world.points[i]
        world.attach(Spring(p1, p2, rd(5, 8), 1))
        # world.attach(Stick(p1, p2, norm(p1.s-p2.s)))

    # world.attach(GravityField())
    world.attach(FField(f=0.35))
    viewport.s = (0, -40, 20)
예제 #3
0
 def __init__(self, s=None, v=None, mass=None, q=None):
     if s:
         self.s = vec(s)
     else:
         self.s = new_vec()
     if v:
         self.v = vec(v)
     else:
         self.v = new_vec()
     self.a = new_vec()
     self.mass = mass or .0
     self.q = q or .0
     self.F = new_vec()
예제 #4
0
 def __init__(self, s=None, v=None, mass=None, q=None):
     if s:
         self.s = vec(s)
     else:
         self.s = new_vec()
     if v:
         self.v = vec(v)
     else:
         self.v = new_vec()
     self.a = new_vec()
     self.mass = mass or 0.0
     self.q = q or 0.0
     self.F = new_vec()
예제 #5
0
 def update(self, dt):
     if self.mass == 0:
         return
     self.a = self.F / self.mass
     v = self.v
     self.s += (v + dt / 2 * self.a) * dt
     self.v += dt * self.a
     self.F = vec((0.0, 0.0, 0.0))
예제 #6
0
 def update(self, dt):
     if self.mass == 0:
         return
     self.a = self.F / self.mass
     v = self.v
     self.s += (v + dt / 2 * self.a) * dt
     self.v += dt * self.a
     self.F = vec((0.0, 0.0, 0.0))
예제 #7
0
 def __init__(self):
     self.s = vec((0, 0, 0))
     self.r = 100
     self.targets = None
예제 #8
0
def new_vec():
    return vec((.0, .0, .0))
예제 #9
0
 def __init__(self, T, q):
     self.k = 0.1
     self.t = 0
     self.T = T
     self.s = vec((0, 0, 0))
     self.q = q
예제 #10
0
 def __init__(self):
     self.s = vec((0, 0, 0))
     self.r = 100
     self.targets = None
예제 #11
0
def new_vec():
    return vec((0.0, 0.0, 0.0))
예제 #12
0
 def __init__(self, T, q):
     self.k = 0.1
     self.t = 0
     self.T = T
     self.s = vec((0, 0, 0))
     self.q = q