Skip to content

Commit

Permalink
orbitalkiller: fixed mass calculation for real trajectory
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Borunov committed Jun 23, 2016
1 parent 16b97ac commit 0d91d20
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
Expand Up @@ -126,7 +126,10 @@ object OrbitDataUpdater {
drawSlidingLines(yy, orbit_color)
if(InterfaceHolder.realTrajectorySwitcher.showRealTrajectory && RealTrajectory.realTrajectory.nonEmpty) {
drawSlidingLines(RealTrajectory.realTrajectory, orbit_color)
//drawSlidingLines(RealTrajectory2.realTrajectory, orbit_color)
/*RealTrajectory.realTrajectory.foreach(p => {
drawFilledCircle(p, 3 / globalScale, orbit_color)
})*/
drawSlidingLines(RealTrajectory2.realTrajectory, ORANGE)
}
}
/*drawLine(new_o.f*scale, new_o.center*scale, GRAY)
Expand Down Expand Up @@ -246,7 +249,10 @@ object OrbitDataUpdater {
openglLocalTransform {
openglMove(planet_state.coord * scale)
drawSlidingLines(RealTrajectory.realTrajectory, orbit_color)
//drawSlidingLines(RealTrajectory2.realTrajectory, orbit_color)
/*RealTrajectory.realTrajectory.foreach(p => {
drawFilledCircle(p, 3 / globalScale, orbit_color)
})*/
drawSlidingLines(RealTrajectory2.realTrajectory, ORANGE)
}
}
if(InterfaceHolder.namesSwitcher.showNames) {
Expand Down
Expand Up @@ -164,13 +164,13 @@ object OrbitalKiller extends ScageScreenAppDMT("Orbital Killer", property("scree
system_cache.clear()
_update_orbits = true
RealTrajectory.init()
//RealTrajectory2.init()
RealTrajectory2.init()
}
}

actionDynamicPeriodIgnorePause(500 / timeMultiplier) {
RealTrajectory.continue()
//RealTrajectory2.continue()
RealTrajectory2.continue()
}

val sun = new Star(
Expand Down
Expand Up @@ -7,9 +7,9 @@ import scala.collection.mutable.ArrayBuffer
import OrbitalKiller._

object RealTrajectory extends RealTrajectoryC
/*object RealTrajectory2 extends RealTrajectoryC {
object RealTrajectory2 extends RealTrajectoryC {
override protected def chooseDt:Double = base_dt
}*/
}

class RealTrajectoryC {
private var real_trajectory:ArrayBuffer[DVec] = ArrayBuffer[DVec]()
Expand Down Expand Up @@ -55,15 +55,13 @@ class RealTrajectoryC {
// выбираем так, чтобы в цикле было ровно 100 итераций.
val seconds_in_this_iteration = math.min((6300*system_evolution_copy.base_dt).toInt, InterfaceHolder.realTrajectorySwitcher.numPoints - curPoints)
val last_step = math.max(1, (seconds_in_this_iteration*(1/system_evolution_copy.base_dt)).toInt)
if(real_trajectory.length >= 3) {
val prev_line = real_trajectory(real_trajectory.length-2) - real_trajectory(real_trajectory.length-3)
val cur_line = real_trajectory(real_trajectory.length-1) - real_trajectory(real_trajectory.length-2)
if (cur_line.absDeg(prev_line) <= angle_diff) {
real_trajectory.remove(real_trajectory.length-1)
dropped += 1
}
}
(1 to last_step).foreach(step => {
system_evolution_copy.bodyState(player_ship.index).foreach(bs => {
if (bs.ang_vel != 0 && math.abs(bs.ang_vel) < angular_velocity_error) {
bs.ang_vel = 0
}
bs.mass = player_ship.thisOrActualProxyShipCurrentMass(system_evolution_copy.tacts)
})
system_evolution_copy.step()
(InterfaceHolder.orbitSwitcher.calculateOrbitAround match {
case Some(idx) =>
Expand Down

0 comments on commit 0d91d20

Please sign in to comment.