Beispiel #1
0
    o = Point.origin()

    random_force = Force.random()
    # print(random_force)
    random_force += gravity
    # print(random_force)

    result = Force.sum([gravity, propulsion, random_force])
    # print("Force.sum:",result)

    x, y = result
    # print(x,y) #Unpacking is compatible for vectors

    f = gravity
    print(result)

    from mycontext import Context

    context = Context()
    position = (0, 0)
    while context.open:
        context.check()
        context.control()
        context.clear()
        context.show()
        position = context.point()
        f.components = list(position)
        f.show(context, o)
        context.flip()
        # context.wait(0.1)
Beispiel #2
0
from mybody import Body
from mycontext import Context

import copy
import mycolors

ps=[Point(10,2),Point(12,5),Point(15,-2)]
f=Form(ps)
b=Body.createFromAbsolute(f)

context=Context()
while context.open:
    context.check()
    context.control()
    context.clear()
    context.show()

    p=Point(*context.point())

    nb=copy.deepcopy(b)
    nba=copy.deepcopy(nb.absolute)
    nba.points.append(p)
    for point in nba.points:
        point.show(context,color=mycolors.BLUE)
    nb.absolute=nba

    nb.show(context)
    nb.absolute.center.show(context,color=mycolors.RED)

    context.flip()