Beispiel #1
0
def Test():
    ball = tableballdefs.Ball(1, 1, 0, 0, 0, 105)
    table = tableballdefs.Table()
    plot = plotballs.PlotBalls(1, table)
    timeStep = 0.1
    frictionForce = Solve(ball, table, timeStep)

    while frictionForce != 0:
        print("topSpin ", ball.topSpin * ball.radius, " velocity ",
              ball.Vel.getLength(), " friction force ", frictionForce)
        frictionForce = Solve(ball, table, timeStep)
Beispiel #2
0
 def __init__(self, numballs, ballList, shot, table = tableballdefs.Table()):
     self.table = table
     self.ballList = ballList
     self.numballs = numballs
     self.shot = shot
     self.plot = plotballs.PlotBalls(self.numballs, self.table)
Beispiel #3
0
 def __init__(self, numballs=4, ballList=[], table=tableballdefs.Table()):
     self.numballs = numballs
     self.table = table
     self.ballList = Rack(numballs, table)
Beispiel #4
0
 def __init__(self, numBalls=1, table = tableballdefs.Table()):
     self.table = table
     self.markerList = ['ro', 'bo', 'go', 'mo', 'co', 'yo', 'ko']
     if numBalls > len(self.markerList): raise "too many balls to plot"
     v = [0, self.table.length, 0, self.table.width]
     plt.axis(v)
Beispiel #5
0
            ball.Vel.x += (accX * timeStep)
            ball.english += (alpha * timeStep)

        return True

    return False


def CalcFF(v0, v1, timeStep, mass, coef):
    acc = (v0 - v1) / timeStep
    norm = acc * mass
    return norm * coef


def CalcAccPara(ff, mass):
    return ff / mass


def CalcAlpha(ff, radius, moi):
    torq = ff * radius
    return torq / moi


if __name__ == "__main__":

    table = tableballdefs.Table()
    ball = tableballdefs.Ball(1, +2, table.length, table.width / 2, 0, 2)

    Carom(ball, table, 0.01)

    print(ball.Vel.x, ball.Vel.y, ball.english)