Skip to content

Commit

Permalink
orbitalkiller: trying to fix hyperbola orbit calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Borunov committed Jun 17, 2016
1 parent 3a0db6f commit 195bd3c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
Expand Up @@ -125,13 +125,24 @@ object OrbitDataUpdater {
openglMove(planet_state.coord * scale)
drawSlidingLines(yy, orbit_color)
}

drawLine(new_o.f*scale, new_o.center*scale, GRAY)
if(_stop_after_number_of_tacts > 0) {
val p = new_o.orbitalPointAfterTime(bs.coord, (_stop_after_number_of_tacts * base_dt * 1000).toLong, ccw)
drawLine(p*scale, (p + (new_o.center - new_o.f).perpendicular*math.signum(p*(new_o.center - new_o.f)))*scale, GRAY)
val p2 = new_o.orbitalPointByTrueAnomalyRad(_stop_in_orbit_true_anomaly)
drawLine(p2*scale, (p2 + (new_o.center - new_o.f).perpendicular*math.signum(p*(new_o.center - new_o.f)))*scale, GRAY)
}


if(InterfaceHolder.namesSwitcher.showNames) {
drawStringInOrbitPoint("P", 0, new_o, orbit_color)
}
val mouse_point = absCoord(mouseCoord) / scale
drawLine(new_o.f * scale, mouse_point * scale, DARK_GRAY)

if (_stop_after_number_of_tacts > 0) {
drawFilledCircle(new_o.orbitalPointByTrueAnomalyRad(_stop_in_orbit_true_anomaly) * scale, 3 / globalScale, RED)
drawFilledCircle(new_o.orbitalPointAfterTime(bs.coord, (_stop_after_number_of_tacts * base_dt * 1000).toLong, ccw) * scale, 3 / globalScale, GREEN)
}

Expand All @@ -157,6 +168,7 @@ object OrbitDataUpdater {

if (set_stop_moment) {
_stop_after_number_of_tacts = (flight_time_msec / 1000 / base_dt).toLong
_stop_in_orbit_true_anomaly = mouse_teta_rad2Pi
set_stop_moment = false
}

Expand Down Expand Up @@ -238,6 +250,7 @@ object OrbitDataUpdater {
drawFilledCircle(orbital_point * scale, 3 / globalScale, orbit_color)

if (_stop_after_number_of_tacts > 0) {
drawFilledCircle(new_o.orbitalPointByTrueAnomalyRad(_stop_in_orbit_true_anomaly) * scale, 3 / globalScale, RED)
drawFilledCircle(new_o.orbitalPointAfterTime(bs.coord, (_stop_after_number_of_tacts * base_dt * 1000).toLong, ccw) * scale, 3 / globalScale, GREEN)
}
val mouse_teta_rad2Pi = new_o.tetaRad2PiInPoint(mouse_point)
Expand All @@ -246,6 +259,7 @@ object OrbitDataUpdater {

if (set_stop_moment) {
_stop_after_number_of_tacts = (flight_time_msec / 1000 / base_dt).toLong
_stop_in_orbit_true_anomaly = mouse_teta_rad2Pi
set_stop_moment = false
}
if (InterfaceHolder.orbParams.calculationOn) {
Expand Down
Expand Up @@ -264,7 +264,7 @@ object OrbitalKiller extends ScageScreenAppDMT("Orbital Killer", property("scree

// на круговой орбите в 200 км от поверхности Земли
val ship_start_position = earth.coord + DVec(-100, earth.radius + 199000)
val ship_init_velocity = satelliteSpeed(ship_start_position, earth.coord, earth.linearVelocity, earth.mass, G, counterclockwise = true)/** 1.15 */
val ship_init_velocity = satelliteSpeed(ship_start_position, earth.coord, earth.linearVelocity, earth.mass, G, counterclockwise = true).n*18760/** 1.15 */

//val ship_start_position = earth.coord + DVec(-100, earth.radius + 198000)
//val ship_init_velocity = speedToHaveOrbitWithParams(ship_start_position, 900000, earth.coord, earth.linearVelocity, earth.mass, G, ccw = false)
Expand All @@ -283,9 +283,9 @@ object OrbitalKiller extends ScageScreenAppDMT("Orbital Killer", property("scree
//val ship_init_velocity = satelliteSpeed(ship_start_position, earth.coord, earth.linearVelocity, earth.mass, G, counterclockwise = true)*1.15

val player_ship = new Ship4(ScageId.nextId,
init_coord = ship_start_position,
init_velocity = ship_init_velocity,
init_rotation = 90
init_coord = DVec(9.594617648145294E7, -8.919468846308415E7)+earth.coord,//DVec(-6.2797933836710215E7, -1.2455588349688923E8)+earth.coord,//ship_start_position,
init_velocity = DVec(28167.17922375556,2692.468259455251),//DVec(30521.418357148767,2855.1265848825283),//ship_init_velocity,
init_rotation = 214.7977970092611//164.6850289440855//90
)

// на круговой орбите в 200 км от поверхности Земли
Expand Down Expand Up @@ -358,6 +358,7 @@ object OrbitalKiller extends ScageScreenAppDMT("Orbital Killer", property("scree

var _set_stop_time:Boolean = false
var _stop_after_number_of_tacts: Long = 0
var _stop_in_orbit_true_anomaly: Double = 0

private def nextStep() {
(1 to timeMultiplier).foreach(step => {
Expand Down Expand Up @@ -915,7 +916,7 @@ object OrbitalKiller extends ScageScreenAppDMT("Orbital Killer", property("scree
keyIgnorePause(KEY_F4, onKeyDown = if (!drawMapMode) viewMode = Landing) // посадка на планету, если не в режиме карты

// функционал толком не работает
//keyIgnorePause(KEY_F5, onKeyDown = saveGame()) // сохранить текущее состояние системы
keyIgnorePause(KEY_F5, onKeyDown = saveGame()) // сохранить текущее состояние системы
//keyIgnorePause(KEY_F6, onKeyDown = loadGame()) // загрузить из файла состояние системы

keyIgnorePause(KEY_I, onKeyDown = {
Expand Down
Expand Up @@ -1698,6 +1698,10 @@ package object orbitalkiller {
}

def _travelTimeOnOrbitMsecCCW(orbital_point1: DVec, orbital_point2: DVec): Long = {
val t1 = tetaDeg360InPoint(orbital_point1)
val t2 = tetaDeg360InPoint(orbital_point2)
val wll_pass_r_p = teta_deg_max < t1 && t1 < 360 && 0 < t2 && t2 < teta_deg_min

val r1 = (orbital_point1 - f).norma
val r2 = (orbital_point2 - f).norma
val s = orbital_point1.dist(orbital_point2)
Expand All @@ -1706,13 +1710,11 @@ package object orbitalkiller {
val chl2 = 1 + (r1 + r2 - s) / (2 * a)

val l1 = math.log(chl1 + math.sqrt(chl1 * chl1 - 1))
val l2 = math.log(chl2 + math.sqrt(chl2 * chl2 - 1))
val l2 = math.log(chl2 + math.sqrt(chl2 * chl2 - 1))*(if(wll_pass_r_p) -1 else 1)
((inv_n * ((math.sinh(l1) - l1) - (math.sinh(l2) - l2))) * 1000).toLong
}

def travelTimeOnOrbitMsecCCW(point1: DVec, point2: DVec, recalculate_points: Boolean = false): Long = {
/*val t1 = tetaDeg360InPoint(point1)
val t2 = tetaDeg360InPoint(point2)*/
if (recalculate_points) {
val orbital_point1 = orbitalPointInPoint(point1)
val orbital_point2 = orbitalPointInPoint(point2)
Expand Down

0 comments on commit 195bd3c

Please sign in to comment.