Deleted the old Orbit.
Deleted the old Orbit.

Also I'm not sure what changed in Orbit.

file:a/Orbit.py -> file:b/Orbit.py
--- a/Orbit.py
+++ b/Orbit.py
@@ -380,7 +380,7 @@
 		PosVector = self.PosVector(M)

 		VelVector = self.VelVector(M)

 		

-		PVector = self.VelVector(M).UnitVector()

+		PVector = VelVector.UnitVector()

 		NVector = (PosVector * VelVector).UnitVector()

 		RVector = PVector * NVector

 		


file:a/Orbit_old.py (deleted)
--- a/Orbit_old.py
+++ /dev/null
@@ -1,172 +1,1 @@
-#!/usr/bin/python3

-

-from Body import Body

-from Vector3D import *

-from math import acos, atan2, cos, pi, sin

-

-class Orbit():

-	def __init__(self, PosVector = None, VelVector = None, Primary = None):

-		'''

-		@param PosVector:

-		@type Vector3D:

-		@param VelVector:

-		@type Vector3D:

-		@param Primary:

-		@type Body:

-		'''

-		self.PosVector = PosVector

-		self.VelVector = VelVector

-		self.Primary = Primary

-	

-	def VisVivaEnergy(self):

-		return self.VelVector.Magnitude() ** 2. / 2 - self.Primary.GravParm() / self.PosVector.Magnitude()

-	

-	def SemiMajorAxis(self):

-		return -self.Primary.GravParm() / (2. * self.VisVivaEnergy())

-	

-	def SpecAngMmntm(self):

-		return self.PosVector * self.VelVector

-	

-	def EccentricityVector(self):

-		return self.VelVector * self.SpecAngMmntm() / self.Primary.GravParm() - self.PosVector.UnitVector()

-	

-	def Eccentricity(self):

-		return self.EccentricityVector().Magnitude()

-	

-	def Inclination(self):

-		h = self.SpecAngMmntm()

-		hZ = h._k

-		return acos(hZ / h.Magnitude())

-	

-	def AscNodeVector(self):

-		return kVector * self.SpecAngMmntm()

-	

-	def LongitudeAscNode(self):

-		n = self.AscNodeVector()

-		

-		try:

-			Omega = acos(n._i / n.Magnitude())

-		except ZeroDivisionError:

-			return None

-		if n._j >= 0:

-			return Omega

-		else:

-			return 2 * pi - Omega

-	

-	def ArgPeriapsis(self):

-		e = self.EccentricityVector()

-		try:

-			n = self.AscNodeVector().UnitVector()

-		except ZeroDivisionError:

-			arg = atan2(e._j / e.Magnitude(), e._i / e.Magnitude())

-			if self.SpecAngMmntm()._k < 0:

-				arg = 2. * pi - arg

-			return arg

-		

-		arg = acos(n.Dot(e) / (n.Magnitude() * e.Magnitude()))

-		

-		if e._k >= 0:

-			return arg

-		else:

-			return 2 * pi - arg

-	

-	def TrueAnomaly(self):

-		e = self.EccentricityVector()

-		r = self.PosVector

-		f = acos(e.Dot(r) / (e.Magnitude() * r.Magnitude()))

-		if r.Dot(self.VelVector) >= 0:

-			return f

-		else:

-			return 2 * pi - f

-	

-	def EccentricAnomaly(self):

-		e = self.Eccentricity()

-		f = self.TrueAnomaly()

-		E = acos((e + cos(f)) / (1 + e * cos(f)))

-		if f <= pi:

-			return E

-		else:

-			return 2 * pi - E

-	

-	def MeanAnomaly(self):

-		E = self.EccentricAnomaly()

-		e = self.Eccentricity()

-		M = E - e * sin(E)

-		return M

-	

-	def PeriapsisVector(self):

-		dummy = Orbit(self.PosVector, self.VelVector, self.Primary)

-		dummy.UpdateTrueAnomaly(0)

-		

-		return dummy.PosVector

-	def Periapsis(self):

-		return self.PeriapsisVector().Magnitude()

-	

-	def ApoapsisVector(self):

-		dummy = Orbit(self.PosVector, self.VelVector, self.Primary)

-		dummy.UpdateTrueAnomaly(pi)

-		

-		return dummy.PosVector

-	def Apoapsis(self):

-		return self.ApoapsisVector().Magnitude()

-	

-	def UpdateFromElements(self, a, e, i, Omega, w, f):

-		p = (a * (1 - e ** 2.) / (1 + e * cos(f)))

-		Rx = p * (cos(Omega) * cos(w + f) - sin(Omega) * cos(i) * sin(w + f))

-		Ry = p * (sin(Omega) * cos(w + f) + cos(Omega) * cos(i) * sin(w + f))

-		Rz = p * sin(i) * sin(w + f)

-		PosVector = Vector3D(Rx, Ry, Rz)

-		

-		Vx = -(self.Primary.GravParm() / p) ** .5 * (cos(Omega) * (sin(w + f) + e * sin(w)) + sin(Omega) * cos(i) * (cos(w + f) + e * cos(w)))

-		Vy = -(self.Primary.GravParm() / p) ** .5 * (sin(Omega) * (sin(w + f) + e * sin(w)) - cos(Omega) * cos(i) * (cos(w + f) + e * cos(w)))

-		Vz = -(self.Primary.GravParm() / p) ** .5 * (sin(i) * (cos(w + f) + e * cos(w)))

-		VelVector = Vector3D(Vx, Vy, Vz)

-		

-		self.PosVector = PosVector

-		self.VelVector = VelVector

-	

-	def UpdateFromShapeAndPos(self, a, e, i, Omega, w, PosVector):

-		self.UpdateFromElements(a, e, i, Omega, w, 0)

-		self.PosVector = PosVector

-		

-# 		f = self.TrueAnomaly()

-# 		self.UpdateFromElements(a, e, i, Omega, w, f)

-# 		

-# 		if (self.PosVector - PosVector).Magnitude() > .001 * self.SemiMajorAxis():

-# 			s  = "Specified PosVector is not on specified orbit!\n"

-# 			s += "Specified PosVector: {0:.2}\n".format(PosVector)

-# 			s += "Calculated PosVector: {0:.2}\n".format(self.PosVector)

-# 			raise ValueError(s)

-	

-	def UpdateTrueAnomaly(self, f):

-		return self.UpdateFromElements(self.SemiMajorAxis(), self.Eccentricity(), self.Inclination(), self.LongitudeAscNode(), self.ArgPeriapsis(), f)

-	

-	def __str__(self):

-		s  = "Orbiting {0}\n".format(self.Primary.Name)

-		s += "a = {0} [m]\n".format(self.SemiMajorAxis())

-		s += "e = {0}\n".format(self.Eccentricity())

-		s += "i = {0} [radians]\n".format(self.Inclination())

-		s += "Ω = {0} [radians]\n".format(self.LongitudeAscNode())

-		s += "ω = {0} [radians]\n".format(self.ArgPeriapsis())

-		s += "υ = {0} [radians]\n".format(self.TrueAnomaly())

-		s += "\n"

-		s += "Current Position: {0} (radius: {1})\n".format(self.PosVector, self.PosVector.Magnitude())

-		s += "Current Velocity: {0} (magnitude: {1})\n".format(self.VelVector, self.VelVector.Magnitude())

-		

-		return s

-

-if __name__ == "__main__":

-	Kerbin = Body("Kerbin", Mass = 5.2915793e22, Radius = 600e3)

-	Orbit1 = Orbit(Primary = Kerbin)

-	Orbit1.UpdateFromElements(4.35e6, 0.28, pi / 6., 0, 3. * pi / 2., pi / 2.)

-	print(Orbit1)

-	

-	Orbit2 = Orbit(Primary = Kerbin)

-	Orbit2.UpdateFromShapeAndPos(Orbit1.PosVector.Magnitude(), 0., 0, 0, 0, Orbit1.PosVector)

-	print(Orbit2)

-	

-	deltaV = Orbit2.VelVector - Orbit1.VelVector

-	print("delta-V to transfer: {0} (magnitude: {1})".format(deltaV, deltaV.Magnitude()))

-	

-	dVPRN = deltaV.ConvertToFrame(Orbit1.VelVector, Orbit1.PosVector, Orbit1.VelVector * Orbit1.PosVector)

-	print("delta-V in Prograde, Radial, Normal: {0} (magnitude {1})".format(dVPRN, dVPRN.Magnitude()))
+