orbital-mechanics

Simulating Orbits

感情迁移 提交于 2019-12-24 18:57:44
问题 So I'm trying to simulate the earth travelling around the sun where the velocity of the earth is determined by the angle its at to the origin and the horizontal. I did this by creating a function that uses tanh (opposite/adjacent) rule for triangles, O_correction(x,y) . The problem is that instead of a circular orbit its instead spiralling out and I'm not sure why. scene = canvas() scene.background = color.white O = 0 ball = sphere(pos=vector(10,0,0), radius=0.1, color=color.blue) x = ball

Python 2.7 Runge Kutta Orbit GUI

大城市里の小女人 提交于 2019-12-24 06:34:34
问题 I'm trying to create a GUI in Python using Tkinter that plots the orbital path of a mass using the Runge-Kutta method. My GUI works fine but my issue is that it only plots a straight line no matter what values I input to the GUI. I was hoping someone could show me what is wrong with my function within the GUI so that it will actually plot the orbit properly. def calcPath(self): M = float(self.entM.get()) m = float(self.entm.get()) G = 6.67e-11 c = 3e8 velocity = np.array([float(self.entvx.get

Controlling an object orbiting a sphere

纵饮孤独 提交于 2019-12-12 16:04:45
问题 I want to let the user control an object moving over the surface of a static sphere. Using two buttons to rotate the direction of the object clockwise and anti-clockwise as it constantly moves forward similar to asteroids. In scene kit there are three different orientation properties for an SCNNode and I really don't know where to start. I understand how to execute everything except the rotation around the sphere. 回答1: You're looking for a parameterization of the surface of the sphere. You

Integrating differential equations of motion for orbit in Runge Kutta in C

守給你的承諾、 提交于 2019-12-12 03:48:45
问题 I'm attempting to integrate the differential equations for planetary orbit using fourth order runge-kutta in C. The first equation that I attempted to integrate was for the position, dr/dt = sqrt((2/mu)*(E-(k/r)) - pow(l, 2)/(pow(mu, 2)*pow(r, 2))). The program compiles correctly but keeps on returning nan, I'm fairly new to C so I'm wondering why that could be. The source code that I'm using is the following: double rk4 ( double t0, double u0, double dt, double f ( double t, double u ) ) { /

Problem in creating leapfrog algorithm for 3-body problem using Python

戏子无情 提交于 2019-12-11 10:37:07
问题 I'm trying to write a code for 3-body problem with leapfrog algorithm. I'm using "Moving Stars Around" by Piet Hut & Jun Makino as a guide. The codes in the guide are written in C, but I'm trying to follow the exact workflow using Python as a start before experimenting with it. The following is my attempt to follow the code from section 5.1. import numpy as np N = 3 #number of bodies m = 1 #mass dt = 0.01 #timestep t_end = 10 #duration r = [] v = [] a = [[0, 0, 0] for i in range(N)] for i in

Python Matplotlib animation frames are overlapping

霸气de小男生 提交于 2019-12-11 02:49:30
问题 I am working on my orbit program, and I have currently only animated the moon with a downward (-y) velocity of -1023. The animation works, but each frame stays on the figure when the next one comes on: Here is my code: import numpy as np import matplotlib.pyplot as plt import math import matplotlib.animation as animation er = 6378100*10#m #earth radius mr = 1737400*10#m #moon radius em = 5.97219*10**24#kg #earth mass mm = 7.34767309*10**22#kg #moon mass d = 384400000#m #distance earth-moon G

Python OrbitalPy Traceback error Cartesian State Vectors Position and Velocity from Keplerian Elements

风格不统一 提交于 2019-12-08 13:41:01
问题 I am trying to get the cartesian position and velocity vectors for each propagation step in my orbit. I am using OrbitalPy http://pythonhosted.org/OrbitalPy/ to generate the orbit with classical Keplerian elements. According to the documentation I should be able to get the state vectors (both position and velocity) from class orbital.utilities.StateVector , but I get a Type Error: new () takes exactly 3 arguments (2 given) Here is the code: from scipy.constants import kilo import orbital from

Find first root of a black box function, or any negative value of same function

做~自己de王妃 提交于 2019-12-01 01:40:32
I have a black box function, f(x) and a range of values for x. I need to find the lowest value of x for which f(x) = 0. I know that for the start of the range of x, f(x) > 0, and if I had a value for which f(x) < 0 I could use regula falsi, or similar root finding methods, to try determine f(x)=0. I know f(x) is continuous, and should only have 0,1 or 2 roots for the range in question, but it might have a local minimum. f(x) is somewhat computationally expensive, and I'll have to find this first root a lot. I was thinking some kind of hill climbing with a degree of randomness to avoid any

Find first root of a black box function, or any negative value of same function

橙三吉。 提交于 2019-11-30 20:24:17
问题 I have a black box function, f(x) and a range of values for x. I need to find the lowest value of x for which f(x) = 0. I know that for the start of the range of x, f(x) > 0, and if I had a value for which f(x) < 0 I could use regula falsi, or similar root finding methods, to try determine f(x)=0. I know f(x) is continuous, and should only have 0,1 or 2 roots for the range in question, but it might have a local minimum. f(x) is somewhat computationally expensive, and I'll have to find this

Plotting elliptical orbits

只谈情不闲聊 提交于 2019-11-30 17:26:42
问题 I'm trying to write a code that plots the elliptical paths of an object using the equation for the ellipse r=a(1-e^2)/(1+e*cos(theta)). I'd also like this data to be put into an array for other use. from numpy import *#Imports Python mathematical functions library import matplotlib.pyplot as plt #Imports plot library from pylab import * a = 5 e = 0.3 theta = 0 while theta <= 2*pi: r = (a*(1-e**2))/(1+e*cos(theta)) print("r = ",r,"theta = ",theta) plt.polar(theta, r) theta += pi/180 plt.show()