Fix #112 by avoiding divide-zero-by-zero

This commit is contained in:
Brandon Rhodes 2016-10-09 22:46:15 -04:00
parent d75f56cdc1
commit 90ef9a08f3
1 changed files with 3 additions and 3 deletions

View File

@ -139,9 +139,9 @@ def _add_deflection(position, observer, deflector, rmass):
qmag = length_of(pq)
emag = length_of(pe)
phat = position / pmag
qhat = pq / qmag
ehat = pe / emag
phat = position / where(pmag, pmag, 1.0) # where() avoids divide-by-zero
qhat = pq / where(qmag, qmag, 1.0)
ehat = pe / where(emag, emag, 1.0)
# Compute dot products of vectors.