Esempio n. 1
0
def lock_water_rectangle(t):
    if lock.mode() == 'Switch':
        y = sim.interpolate(t, lock.mode_time(), lock.scheduled_time(
        ), ylevel[lock.side], ylevel[-lock.side])
    else:
        y = ylevel[lock.side]
    return (xdoor[left], -waterdepth, xdoor[right], y)
Esempio n. 2
0
 def y(self, t):
     if self.car.mode() == 'Move':
         return sim.interpolate(
             t, self.car.mode_time(), self.car.scheduled_time(),
             self.car.floor.y, self.car.nextfloor.y)
     else:
         return self.car.floor.y
Esempio n. 3
0
def lock_y(t):
    if lock.mode() == 'Switch':
        y = sim.interpolate(t, lock.mode_time(), lock.scheduled_time(),
                            ylevel[lock.side], ylevel[-lock.side])
    else:
        y = ylevel[lock.side]
    return y
Esempio n. 4
0
 def y(self, t):
     if self.mode() == "Move":
         y = sim.interpolate(t, self.mode_time(), self.scheduled_time(),
                             self.floor.y, self.nextfloor.y)
     else:
         y = self.floor.y
     return y
Esempio n. 5
0
 def y(self, t):
     tangle = sim.interpolate(t, self.t0, self.t1, 0, 2 * math.pi)
     sint = math.sin(tangle)
     cost = math.cos(tangle)
     x, y = (100 + self.r * cost - 0 * sint,
             100 + self.r * sint + 0 * cost)
     return y
def animation_pre_tick(self, t):
    if lock.mode() == 'Switch':
        y = sim.interpolate(t, lock.mode_time(), lock.scheduled_time(),
                            ylevel[lock.side], ylevel[-lock.side])
    else:
        y = ylevel[lock.side]
    lockqueue.animate(x=xdoor[-lock.side],
                      y=y,
                      direction='w' if lock.side == left else 'e')
Esempio n. 7
0
def animation_pre_tick(self, t):
    for car in cars:
        if car.mode() == 'Move':
            y = sim.interpolate(t, car.mode_time(), car.scheduled_time(),
                                car.floor.y, car.nextfloor.y)
        else:
            y = car.floor.y
        car.visitors.animate(x=xcar[car], y=y, direction='e')
        car.pic.update(y0=y)
 def y(self, t):  # This is used by the animation to define the level of a car
     # When the car is in mode 'Move' the level (y) will be varying over time
     if self.mode() == "Move":
         y = sim.interpolate(t, self.mode_time(), self.scheduled_time(), self.floor.y, self.nextfloor.y)
         # linear interpolation between self.floor.y and self.next_floor.y based on
         # the time it left self.floor.y (i.e. self.mode_time() and
         # the time it arrives at self.next_floor.y (i.e. self.scheduled_time())
     else:
         y = self.floor.y
     return y
Esempio n. 9
0
 def fillcolor(self, t):
     f = sim.interpolate(t, self.t0, self.t1, 0, 1)
     if f < 0.5:
         return sim.colorinterpolate(f, 0, 0.5,
                                     sim.colorspec_to_tuple('red'),
                                     sim.colorspec_to_tuple('blue'))
     else:
         return sim.colorinterpolate(f, 0.5, 1,
                                     sim.colorspec_to_tuple('blue'),
                                     sim.colorspec_to_tuple('green'))
Esempio n. 10
0
def lock_water_rectangle(t):
    if lock.mode() == "Switch":
        y = sim.interpolate(t, lock.mode_time(), lock.scheduled_time(),
                            ylevel[lock.side], ylevel[-lock.side])
    # Interpolate is a method of Salabim that provides linear interpolation: (t, t0, t1, f(t0), f(t1))
    # mode_time() is a method of sim.Component that returns the time the component got its latest mode
    # schedule_time() is a method of Component that returns the time the component is scheduled for
    else:
        y = ylevel[lock.side]
        # When not switching, the water level will be one of the door levels
    return (xdoor[left], -waterdepth, xdoor[right], y)
Esempio n. 11
0
 def text(self,t):
     angle=sim.interpolate(t,self.t0,self.t1,0,360)
     return '{:3.0f}'.format(angle)
Esempio n. 12
0
 def angle(self,t):
     return sim.interpolate(t,self.t0,self.t1,0,360)
Esempio n. 13
0
 def y(self, t):
     if lock.mode() == 'Switch':
         return sim.interpolate(t, lock.mode_time(), lock.scheduled_time(),
             ylevel[lock.side], ylevel[-lock.side])
     else:
         return ylevel[lock.side]
Esempio n. 14
0
 def x(self, t):
     return sim.interpolate(
         sim.interpolate(t, self.t0, self.t1, 0, 1)**2, 0, 1, self.x0,
         self.x1)