def step_impl(context): assert context.v1 -context.v2 == vector(-2,-4,-6)
class env: def __init__(self, gravity, wind): self.gravity = gravity self.wind = wind class proj: def __init__(self, position, velocity): self.position = position self.velocity = velocity def tick(e, p): position = p.position + p.velocity velocity = p.velocity + e.gravity + e.wind return proj(position, velocity) c = canvas(900, 500) p = proj(point(0, 1, 0), vector(1, 1.8, 0).normalize() * 11.25) e = env(vector(0, -0.1, 0), vector(-0.01, 0, 0)) for i in range(0, 200): p = tick(e, p) print(p.position, p.velocity) c.set(int(p.position.x), c.height - int(p.position.y), color(1, 0, 0)) c.save("test.ppm")
def step_impl(context): context.v1 = vector(3,2,1)
def step_impl(context): context.v2 = vector(5,6,7)
def step_impl(context): assert context.a.cross(context.b) == vector(-1,2,-1)
def step_impl(context): assert context.b.cross(context.a) == vector(1,-2,1)
def step_impl(context): context.a = vector(1,2,3)
def step_impl(context): context.b = vector(2,3,4)
def step_impl(context): assert context.v.normalize() == vector(0.26726, 0.53452, 0.80178)
def step_impl(context): assert context.v.normalize() == vector(1,0,0)
def step_impl(context): context.v = vector(4,0,0)
def step_impl(context): context.v = vector(-1,-2,-3)
def step_impl(context): context.v = vector(0,1,0)