Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero distance crash #3

Open
DaddyTheRunner opened this issue Oct 12, 2015 · 1 comment
Open

Zero distance crash #3

DaddyTheRunner opened this issue Oct 12, 2015 · 1 comment

Comments

@DaddyTheRunner
Copy link

The solar system simulator (part 6) crashes if two planets happen to have zero distance between them. Here's the error message Python generates:

$ python simulator.py
Traceback (most recent call last):
  File "simulator.py", line 144, in <module>
    calculateMovement()
  File "simulator.py", line 66, in calculateMovement
    nDirection = (direction[0] / magnitude, direction[1] / magnitude) # Normalis
ed Vector pointing in the direction of the force
ZeroDivisionError: float division by zero
@seanmtracey
Copy link
Owner

Ah, these are always fun! I'll write some code in a little bit to check for a 0 before we try and divide anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants