Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
calculateDeltaV: function(data){
var radiusOfBody = data["b.radius["+ this.vessel.orbitingBody.id +"]"]
var r1 = data['o.ApA'] + radiusOfBody
var r2 = data['tar.o.ApA'] + radiusOfBody
var mu = data["b.o.gravParameter["+ this.vessel.orbitingBody.id +"]"];
var factor1 = Math.sqrt(mu/r1)
var factor2 = Math.sqrt((2 * r2)/(r1 + r2))
this.deltaV = factor1 * (factor2 - 1)
// console.log("delta V1: " + this.deltaV)
},
getVesselAndTargetInfo: function(data){
if(this.isnoTarget(data)){return}
this.targetBody = this.datalink.getOrbitalBodyInfo(data['tar.name'])
this.targetBody.orbitingBody = this.datalink.getOrbitalBodyInfo(data['tar.o.orbitingBody'])
this.targetBody.periapsis = data['tar.o.ApA']
this.vessel.orbitingBody = this.datalink.getOrbitalBodyInfo(data['v.body'])
this.vessel.periapsis = data['o.ApA']
this.vessel.altitude = data['v.altitude']
this.vessel.orbitalVelocity = data['v.orbitalVelocity']
this.datalink.subscribeToData([
"b.o.gravParameter["+ this.vessel.orbitingBody.id +"]",
"b.radius["+ this.vessel.orbitingBody.id +"]",
"b.o.phaseAngle["+ this.targetBody.id +"]"
])
},
window.requestAnimationFrame(function(){
this.fields.vesselBody.update(data['v.body'])
this.fields.targetBody.update(data['v.body'])
this.fields.vesselAltitude.update(DataFormatters.distanceString(data['v.altitude']))
this.fields.vesselApoapsis.update(DataFormatters.distanceString(data['o.ApA']))
this.fields.targetApoapsis.update(DataFormatters.distanceString(data['tar.o.ApA']))
this.fields.vesselPeriapsis.update(DataFormatters.distanceString(data['o.PeA']))
this.fields.targetPeriapsis.update(DataFormatters.distanceString(data['tar.o.PeA']))
this.fields.vesselTimeToApoapsis.update("-" + TimeFormatters.durationString(data['o.timeToAp']))
this.fields.targetTimeToApoapsis.update("-" + TimeFormatters.durationString(data['tar.o.timeToAp']))
this.fields.vesselTimeToPeriapsis.update("-" + TimeFormatters.durationString(data['o.timeToPe']))
this.fields.targetTimeToPeriapsis.update("-" + TimeFormatters.durationString(data['tar.o.timeToPe']))
this.fields.vesselInclination.update(DataFormatters.degreeString(data['o.inclination']))
this.fields.targetInclination.update(DataFormatters.degreeString(data['tar.o.inclination']))
this.fields.vesselEccentricity.update(data['o.eccentricity'].toFixed(3))
this.fields.targetEccentricity.update(data['tar.o.eccentricity'].toFixed(3))