Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from visual import *
- scene = display(x=0, y=0, height=400, range=10)
- scene.up = vector(0,0,1)
- scene.forward = vector(0,-1,0)
- ball = sphere(radius=1.0, color=color.cyan)
- ball.pos = (0.0,0.0,1.0)
- ball.velocity = vector(0, 0, 1.0)
- ball.accel = vector(0, 0, -9.8)
- dt = 0.01
- t = 0.0
- e = 1.0
- b = 0.01
- m = 1.0
- while t < 10:
- rate(200)
- ball.pos = ball.pos + ball.velocity * dt
- ball.accel = vector(0, 0, -9.8)-(b/m)*ball.velocity.mag*ball.velocity
- ball.velocity = ball.velocity + ball.accel * dt
- if ball.pos.z < 0:
- ball.velocity = -e* ball.velocity
- print('抵抗なしX= -0.039939999999999455,抵抗ありX=',ball.pos.z)
- t = t + dt
Add Comment
Please, Sign In to add comment