17 from ctypes
import CDLL, c_char_p
21 SWARMDIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
24 DEFAULT_PLACES = [
'lib', os.path.join(SWARMDIR,
'build/lib'), os.path.join(SWARMDIR,
'lib') ]
27 _, fn, _ = imp.find_module(
'libswarmng_ext', sys.path + DEFAULT_PLACES)
31 so_hexversion = so_dll.python_hexversion
32 so_version = so_dll.python_version
33 so_version.restype = c_char_p
36 if so_hexversion() != sys.hexversion :
37 print(
"The swarmng library was build for Python version %s, but you are running %s" % (so_version(), platform.python_version()))
40 imp.load_dynamic(
'libswarmng_ext', fn)
42 from libswarmng_ext
import *
43 from collections
import namedtuple
86 KeplerianCoordinates = namedtuple(
'KeplerianCoordinates',
87 [
'a',
'e',
'i',
'O',
'w',
'M' ])
106 ((x,y,z),(vx,vy,vz),mass) = planet
107 ((cx,cy,cz),(cvx,cvy,cvz),cmass) = center
108 (a,e,i,O,w,M) =
calc_keplerian_for_cartesian(x-cx,y-cy,z-cz, vx-cvx,vy-cvy,vz-cvz, mass + cmass)
109 return KeplerianCoordinates(a,e,i,O,w,M)