Skip to content

Instantly share code, notes, and snippets.

@Gnonthgol
Last active April 8, 2020 11:52
Show Gist options
  • Save Gnonthgol/8121694 to your computer and use it in GitHub Desktop.
Save Gnonthgol/8121694 to your computer and use it in GitHub Desktop.
Transfer angles for every circular orbit
#! /usr/bin/python
#
# ----------------------------------------------------------------------------
# "THE BEER-WARE LICENSE" (Revision 42):
# <Gnonthgol@gmail.com> wrote this file. As long as you retain this notice you
# can do whatever you want with this stuff. If we meet some day, and you think
# this stuff is worth it, you can buy me a beer in return Gnonthgol
# ----------------------------------------------------------------------------
#
from math import pi, sqrt, sin, cos
def ang(r):
if r == 0:
return 0.0
return -pi*(1-(1/(2*sqrt(2))*sqrt((1/r+1)**3)))
def xy(r):
if r == 0:
return (0.0, 0.0)
a = ang(r)
return (cos(a)*r, sin(a)*r)
r = (0.001*400)**2
co = [xy((0.001*i)**2) for i in range(400, 2500)]
path = "M " + " ".join(["%.4f %.4f"%(x,y) for (x,y) in co])
print """<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="1080px" height="1920px" viewBox="0 0 1.1 1.1"
xmlns="http://www.w3.org/2000/svg" version="1.1">
<title>Transfer angles</title>
<desc>Hohman transfer angles in any system</desc>
<style type="text/css"><![CDATA[
.Graph {{ fill:none; stroke:green; stroke-width:0.01 }}
.Sun {{ fill:none }}
.Earth {{ fill:#000000 }}
.Orbit {{ fill:none; stroke:#888888; stroke-width:0.01 }}
.Cross {{ fill:none; stroke:grey; stroke-width:0.005 }}
]]></style>
<g transform="translate(0.5,1) scale(0.5)">
<path class="Graph" d="{path}" />
<circle class="Graph" cx="0" cy="0" r="{r}" />
<circle class="Sun" cx="0" cy="0" r="0.1" />
<path class="Cross" d="M -0.1 0 L 0.1 0 M 0 -0.1 L 0 0.1" />
<circle class="Orbit" cx="0" cy="0" r="1" />
<circle class="Earth" cx="1" cy="0" r="0.03" />
<path class="Cross" d="M 0.97 0 L 1.03 0 M 1 -0.03 L 1 0.03" />
</g>
</svg>""".format(path=path, r=r)
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment