//<summary> //Takes in position and velocity realtive to the body being orbited //</summary> private void calculateInitialOrbitalElements(Vector2 position, Vector2 velocity) { gravityElements.Mu = GlobalElements.GRAV_CONST * gravityElements.MassiveBody.GetComponent <MassiveBodyElements>().mass; gravityElements.Position = position; gravityElements.velocity = velocity; //Calculate Global Tranformation Vector gravityElements.GlobalTransformationVector = OrbitalHelper.calculateGlobalTranformationVector(gravityElements.MassiveBody); //Calculate eccentricity gravityElements.Eccentricity = OrbitalHelper.calculateEccentricity(position, velocity, gravityElements.Mu); //Determine orbit type gravityElements.OrbitType = OrbitalHelper.determineOrbitType(gravityElements.Eccentricity); //Calculate Mechanical Energy gravityElements.MechanicalEnergy = OrbitalHelper.calculateMechanicalEnergy(gravityElements.Position, gravityElements.velocity, gravityElements.Mu, gravityElements.OrbitType); //Calculate Semi Major Axis gravityElements.SemiMajorAxis = OrbitalHelper.calculateSemiMajorAxis(gravityElements.MechanicalEnergy, gravityElements.Mu, gravityElements.OrbitType); //Calculate SemiLatusRectum gravityElements.SemiLatusRectum = OrbitalHelper.calculateSemiLatusRectum(gravityElements.SemiMajorAxis, gravityElements.Eccentricity, gravityElements.Perigee, gravityElements.OrbitType); //Calculate Perigee gravityElements.Perigee = OrbitalHelper.calculatePerigee(gravityElements.SemiMajorAxis, gravityElements.Eccentricity, gravityElements.OrbitType); //Calculate Apogee gravityElements.Apogee = OrbitalHelper.calculateApogee(gravityElements.SemiMajorAxis, gravityElements.Eccentricity, gravityElements.OrbitType); //Calculate Center gravityElements.Center = OrbitalHelper.calculateCenter(gravityElements.SemiMajorAxis, gravityElements.Perigee, gravityElements.OrbitType); //Calculate GlobalRotationAngle gravityElements.GlobalRotationAngle = OrbitalHelper.calculateGlobalRotationAngle(gravityElements.Eccentricity, gravityElements.OrbitType); //Find orbital directions gravityElements.Clockwise = OrbitalHelper.clockwiseOrbit(gravityElements.Position, gravityElements.velocity); gravityElements.TowardsPerigee = OrbitalHelper.towardsPerigeeOrbit(gravityElements.velocity, gravityElements.Eccentricity, gravityElements.OrbitType); //Calculate trueAnomaly gravityElements.TrueAnomaly = OrbitalHelper.calculateTrueAnomaly(gravityElements.Eccentricity, gravityElements.Position, gravityElements.TowardsPerigee, gravityElements.Clockwise, gravityElements.OrbitType); //Calculate Eccentric Anomaly gravityElements.EccentricAnomaly = OrbitalHelper.calculateEccentricAnomaly(gravityElements.Eccentricity, gravityElements.TrueAnomaly, gravityElements.TowardsPerigee, gravityElements.OrbitType); //Calculate Anomaly at current epoch gravityElements.AnomalyAtEpoch = OrbitalHelper.calculateAnomalyAtCurrentEpoch(gravityElements.Eccentricity, gravityElements.EccentricAnomaly, gravityElements.Clockwise, gravityElements.OrbitType); gravityElements.MeanAnomaly = gravityElements.AnomalyAtEpoch; //Calculate Angular Momentum gravityElements.AngularMomentum = OrbitalHelper.calculateAngularMomentum(gravityElements.Eccentricity, gravityElements.Perigee, gravityElements.SemiMajorAxis, gravityElements.SemiLatusRectum, gravityElements.Mu, gravityElements.OrbitType); //Calculate time at epoch gravityElements.TimeAtEpoch = OrbitalHelper.calculateTimeAtEpoch(gravityElements.Eccentricity, gravityElements.EccentricAnomaly, gravityElements.SemiMajorAxis, gravityElements.Mu, gravityElements.Clockwise, gravityElements.TowardsPerigee, gravityElements.OrbitType); }