コード例 #1
0
ファイル: movement.py プロジェクト: cssd2019/geneticbike
    dx[1, :] = np.subtract(mB.locations[0, :], mB.locations[0, 1])
    dx[2, :] = np.subtract(mB.locations[0, :], mB.locations[0, 2])
    dx[3, :] = np.subtract(mB.locations[0, :], mB.locations[0, 3])

    F[0, :] = np.sum(-k * dx, axis=1)

    # computation of forces in y-direction

    dy = np.zeros((4, 4))
    dy[0, :] = np.subtract(mB.locations[1, :], mB.locations[1, 0])
    dy[1, :] = np.subtract(mB.locations[1, :], mB.locations[1, 1])
    dy[2, :] = np.subtract(mB.locations[1, :], mB.locations[1, 2])
    dy[3, :] = np.subtract(mB.locations[1, :], mB.locations[1, 3])

    F[1, :] = np.sum(-k * dy - m * g, axis=1)

    # computation of acceleration
    a = F / m

    # computation of velocity
    v = v + a * dt
    print(v)
    time.sleep(3)

    # computation of new locations of the points
    mB.locations = mB.locations + v * dt
    print(mB.locations)
    time.sleep(5.5)
    if mB.locations[1, 2] == 0 or mB.locations[1, 3] == 0:
        moving = False
コード例 #2
0
dt = 0.1
a_Aw = 0.4

floor = np.random.rand(2,10)
floor[0,:] = np.array([0,1,2,3,4,5,6,7,8,9])
locations = list()

# mB is the moving bike 
mB = Bike("random")

# masses of points as activeWheel, passiveWheel, handle1, handle2 in kg
m = np.array([0.5, 0.5, 30, 30])

v = np.zeros((2, 2))

mB.locations = mB.locations[:,0:2]
mB.locations[1,:] += 1
inair_firstPoint = True
inair_secondPoint = True
t = 0
locations.append(mB.locations)

# gravity applies to the bike

# touch point for point 1
indexFloor = floor[0,:] == np.floor(mB.locations[0,0])
indexCeil = floor[0,:] == np.ceil(mB.locations[0,0])
indexEq = floor[0,:] == mB.locations[0,0]
if np.any(indexEq):
    y_touch_1 = floor[1,indexEq]
else:
コード例 #3
0
a_Aw = 4

locations = list()

floor = read_np_random_surface('./random_surface.csv')

# mB is the moving bike 
mB = Bike("random")

# masses of points as activeWheel, passiveWheel, handle1, handle2 in kg
m = np.array([0.5, 0.5, 30, 30])

v = np.zeros((2, 1))

# initial velocities of points - that is calculated initially based on acceleration of active wheel ???
mB.locations = mB.locations[:,0:1]
mB.locations[1,:] += 1
inair = True
t = 0
locations.append(mB.locations)

# gravity applies to the bike
while inair == True:
    v[1,0] = - g * dt
    mB.locations = mB.locations + v * dt
    indexFloor = floor[0,:] == np.floor(mB.locations[0,0])
    indexCeil = floor[0,:] == np.ceil(mB.locations[0,0])
    indexEq = floor[0,:] == mB.locations[0,0]
    if np.any(indexEq):
        y_touch = floor[1,indexEq]
    else: