ggAstro Astronautics¶
ggame extensions for modeling spacecraft in planetary orbit
Planet¶
-
class
ggame.astro.
Planet
(**kwargs)[source]¶ Initialize the Planet object.
Optional keyword parameters are supported:
Parameters: - viewscale (float) – Pixels per meter in graphics display. Default is 10.
- radius (float) – Radius of the planet in meters. Default is Earth radius.
- planetmass (float) – Mass of the planet in kg. Default is Earth mass.
- color (int) – Color of the planet. Default is greenish (0x008040).
- viewalt (float) – Altitude of initial viewpoint in meters. Default is rocket altitude.
- viewanom (float) – True anomaly (angle) of initial viewpoint in radians. Default is the rocket anomaly.
- viewanomd (float) – True anomaly (angle) of initial viewpoing in degrees. Default is the rocket anomaly.
Example:
""" Example of using Planet class. """ from ggame.astro import Planet EARTH = Planet(viewscale=0.00005) EARTH.run()
Rocket¶
-
class
ggame.astro.
Rocket
(planet, **kwargs)[source]¶ Rocket is a class for simulating the motion of a projectile through space, acted upon by arbitrary forces (thrust) and by gravitaitonal attraction to a single planetary object.
Required parameters:
Parameters: planet (Planet) – Reference to a Planet
object.Optional keyword parameters are supported:
Parameters: - bitmap (str) – Url of a suitable bitmap image for the rocket (png recommended), default is images/rocket.png
- bitmapscale (float) – Scale factor for bitmap. Default is 0.1
- velocity (float) – Initial rocket speed. Default is zero.
- directiond (float) – Initial rocket direction in degrees. Default is zero.
- direction (float) – Initial rocket direction in radians. Default is zero.
- tanomalyd (float) – Initial rocket true anomaly in degrees. Default is 90.
- tanomaly (float) – Initial rocket true anomaly in radians. Default is pi/2.
- altitude (float) – Initial rocket altitude in meters. Default is zero.
- showstatus (bool) – Boolean displays flight parameters on screen. Default is True.
- int) statuspos ((int,) – Tuple with screen x,y coordinates of flight parameters. Default is upper left.
- statuslist (list[str]) – List of status names to include in flight parameters. Default is all, consisting of: “velocity”, “acceleration”, “course”, “altitude”, “thrust”, “mass”, “trueanomaly”, “scale”, “timezoom”, “shiptime”
- leftkey (str) – A
ggame.event.KeyEvent
key identifier that will serve as the “rotate left” key while controlling the ship. Default is ‘left arrow’. - rightkey (str) – A
ggame.event.KeyEvent
key identifier that will serve as the “rotate right” key while controlling the ship. Default is ‘right arrow’.
Following parameters may be set as a constant value, or pass in the name of a function that will return the value dynamically or the name of a ggmath UI control that will return the value.
Parameters: - or float timezoom (function) – Scale factor for time zoom. Factor = 10^timezoom
- or float heading (function) – Direction to point the rocket in (must be radians)
- or float mass (fucntion) – Mass of the rocket (must be kg)
- or float thrust (function) – Thrust of the rocket (must be N)
Animation related parameters may be ignored if no sprite animation:
Parameters: - bitmapframe (Frame) – ((x1,y1),(x2,y2)) tuple defines a region in the bitmap
- bitmapqty (int) – Number of bitmaps – used for animation effects
- bitmapdir (str) – “horizontal” or “vertical” use with animation effects. Default is “horizontal”
- bitmapmargin (int) – Pixels between successive animation frames
- tickrate (float) – Frequency of spacecraft dynamics calculations (Hz)
Example:
""" Example of using Rocket class. """ from ggame.astro import Planet, Rocket EARTH = Planet(viewscale=0.00005) EARTH.run() ROCKET = Rocket(EARTH, altitude=400000, velocity=7670, timezoom=2)
-
tickrate
= None¶ Target animation frames per second.
-
localheading
= None¶ Heading (angle) of travel
-
timezoom
= None¶ Reference to a function that will dynamically determine the time zoom factor. An integer: 1,2,3 faster, -1, slower.
-
heading
= None¶ Reference to a function that will dynamically calculate spaceship orientation or heading (in radians)
-
mass
= None¶ Reference to a function that will dynamically calculate the spaceship mass (in kg).
-
thrust
= None¶ Reference to a funtion that will dynamically calculate the rocket thrust (in N).
-
addStatusReport
(statuslist, statusfuncs, statusselect)[source]¶ Accept list of all status names, all status text functions, and the list of status names that have been selected for display.
Parameters: - statuslist (list[str]) – List of status names to include in flight parameters. Default is all, consisting of: “velocity”, “acceleration”, “course”, “altitude”, “thrust”, “mass”, “trueanomaly”, “scale”, “timezoom”, and “shiptime”.
- statusfuncs (list[func]) – List of function references corresponding to statuslist parameter.
- statusselect (list[str]) – List of names chosen from statuslist to display.
Returns: None
-
xyposition
¶ Report the x,y tuple for logical position of the spaceship.
-
tanomalyd
¶ Report/set the spaceship position as a direction relative to central body (degrees).
-
altitude
¶ Report/set the spaceship altitude of planet surface in meters.
-
velocity
¶ Report the spaceship velocity scalar in m/s.
-
acceleration
¶ Report the spaceship acceleration scalar in m/s.
-
tanomaly
¶ Report/set the spaceship position as a direction relative to central body (radians).
-
r
¶ Report the spaceship distance (radius) from central body center of mass.