Пример #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