little optimisation

This commit is contained in:
tTh 2022-12-13 23:03:54 +01:00
parent 296ae4dfc2
commit bc7de7e7eb
1 changed files with 4 additions and 2 deletions

View File

@ -102,12 +102,14 @@ function compute_gravity(fx, fy, body)
rx = fx - body%posx
ry = fy - body%posy
dist = sqrt( (rx*rx) + (ry*ry) )
! ??? dist = sqrt( (rx*rx) + (ry*ry) )
dist = (rx*rx) + (ry*ry)
if (dist .LT. 0.08) then
! write (0, *) "dist too small ", dist
compute_gravity = 0e0
else
compute_gravity = body%mass / (dist ** 2)
! ??? compute_gravity = body%mass / (dist ** 2)
compute_gravity = body%mass / dist
endif
end function