Ball in a spinning ring · Python

Flashcards for Python lesson 7: Stepping through time

Read the front, say the back to yourself, then open the card.

  • Euler step

    position += velocity · dt; velocity += acceleration · dt.

  • Reflection

    v − 2·(v · n)·n, with n the wall’s unit normal.

  • np.arctan2(y, x)

    The angle of the point (x, y), from −π to π.

  • break

    Leaves the loop it is in, at once.

  • Energy check

    ½·|v|² + g·y should stay nearly constant without friction: a test of a simulation.

Back to the lesson