def makeBox(pos=position_init, vel=velocity_init):
    if (True):
        box = btConvexHullShape()
        box.addPoint(btVector3(-1.0, 1.0, -1.0))
        box.addPoint(btVector3(-1.0, -1.0, -1.0))
        box.addPoint(btVector3(-1.0, -1.0, 1.0))
        box.addPoint(btVector3(-1.0, 1.0, 1.0))
        box.addPoint(btVector3(1.0, 1.0, 1.0))
        box.addPoint(btVector3(1.0, 1.0, -1.0))
        box.addPoint(btVector3(1.0, -1.0, -1.0))
        box.addPoint(btVector3(1.0, -1.0, 1.0))
    else:
        box = btBoxShape(btVector3(1.0, 1.0, 1.0))

    # a bullet shape with a mass (1.0)
    box1 = BulletWeightedShape(box, 1.0)

    # A Bullet Dynamical System : a shape + a mass + position and velocity
    body = BulletDS(box1,
                    [0, 0, pos, 1., 0, 0, 0],
                    [0, 0, vel, 0., 0., 0.])
    
    # set external forces
    weight = [0, 0, - box1.mass() * g]
    body.setFExtPtr(weight)

    return body
#
position_init = 10
velocity_init = 0

if (True):
    box = btConvexHullShape()
    box.addPoint(btVector3(-1.0, 1.0, -1.0))
    box.addPoint(btVector3(-1.0, -1.0, -1.0))
    box.addPoint(btVector3(-1.0, -1.0, 1.0))
    box.addPoint(btVector3(-1.0, 1.0, 1.0))
    box.addPoint(btVector3(1.0, 1.0, 1.0))
    box.addPoint(btVector3(1.0, 1.0, -1.0))
    box.addPoint(btVector3(1.0, -1.0, -1.0))
    box.addPoint(btVector3(1.0, -1.0, 1.0))
else:
    box = btBoxShape(btVector3(1.0, 1.0, 1.0))

# a bullet shape with a mass (1.0)
box1 = BulletWeightedShape(box, 1.0)

# A Bullet Dynamical System : a shape + a mass + position and velocity
body = BulletDS(box1, [0, 0, position_init, 1., 0, 0, 0],
                [0, 0, velocity_init, 0., 0., 0.])

# set external forces
weight = [0, 0, -box1.mass() * g]
body.setFExtPtr(weight)

#
# Model
#
bouncingBox = Model(t0, T)

# add the dynamical system to the non smooth dynamical system
bouncingBox.nonSmoothDynamicalSystem().insertDynamicalSystem(body)

#
# Simulation
#

# (1) OneStepIntegrators
osi = MoreauJeanOSI(theta)
osi.insertDynamicalSystem(body)

ground = btCollisionObject()
ground.setCollisionFlags(btCollisionObject.CF_STATIC_OBJECT)
groundShape = btBoxShape(btVector3(30, 30, .5))
basis = btMatrix3x3()
basis.setIdentity()
ground.getWorldTransform().setBasis(basis)
ground.setCollisionShape(groundShape)
ground.getWorldTransform().getOrigin().setZ(-.5)

# (2) Time discretisation --
timedisc = TimeDiscretisation(t0, h)

# (3) one step non smooth problem
osnspb = FrictionContact(3)

osnspb.numericsSolverOptions().iparam[0] = 1000
osnspb.numericsSolverOptions().dparam[0] = 1e-5
osnspb.setMStorageType(1)
Beispiel #4
0
#
position_init = 10
velocity_init = 0

if (True):
    box = btConvexHullShape()
    box.addPoint(btVector3(-1.0, 1.0, -1.0))
    box.addPoint(btVector3(-1.0, -1.0, -1.0))
    box.addPoint(btVector3(-1.0, -1.0, 1.0))
    box.addPoint(btVector3(-1.0, 1.0, 1.0))
    box.addPoint(btVector3(1.0, 1.0, 1.0))
    box.addPoint(btVector3(1.0, 1.0, -1.0))
    box.addPoint(btVector3(1.0, -1.0, -1.0))
    box.addPoint(btVector3(1.0, -1.0, 1.0))
else:
    box = btBoxShape(btVector3(1.0, 1.0, 1.0))

# a bullet shape with a mass (1.0)
box1 = BulletWeightedShape(box, 1.0)

# A Bullet Dynamical System : a shape + a mass + position and velocity
body = BulletDS(box1,
                [0, 0, position_init, 1., 0, 0, 0],
                [0, 0, velocity_init, 0., 0., 0.])

# set external forces
weight = [0, 0, - box1.mass() * g]
body.setFExtPtr(weight)

#
# Model