示例#1
0
    //<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);
    }
    private void updateNode()
    {
        Vector2 nodePosition = node.getNodePosition();

        bool   nodeTowardsPerigee = OrbitalHelper.towardsPerigeeOrbit(mouseTrueAnomaly, shipElements.Clockwise);
        double nodeSpeed          = OrbitalHelper.calculateSpeed(nodePosition, shipElements.SemiMajorAxis, shipElements.Mu, shipElements.OrbitType);
        double nodeVelocityAngle  = OrbitalHelper.calculateVelocityAngle(nodePosition, shipElements.Eccentricity, shipElements.SemiMajorAxis, mouseTrueAnomaly, shipElements.GlobalRotationAngle, shipElements.Clockwise, nodeTowardsPerigee, shipElements.OrbitType);

        Vector2 nodeVelocity = OrbitalHelper.assembleVelocityVector(nodeVelocityAngle, nodeSpeed);

        GravityElementsClass newOrbit = calculateInitialOrbitalElements(nodePosition, nodeVelocity + thrustVector, shipElements.massiveBody);

        node = new Node(newOrbit, mouseTrueAnomaly, nodePosition);

        patchedConics.updatePotentialEncounters(node.getManeuver());
    }
示例#3
0
    private void calculateNextOrbitalElements()
    {
        //update timestep
        gravityElements.TimeStep = GlobalElements.timeStep;

        //Adjust tranformation vector
        gravityElements.GlobalTransformationVector = gravityElements.MassiveBody.transform.position;

        //Calculate next meanAnomaly
        gravityElements.MeanAnomaly = OrbitalHelper.calculateMeanAnomaly(gravityElements.Eccentricity, gravityElements.SemiMajorAxis, gravityElements.AnomalyAtEpoch,
                                                                         gravityElements.TimeStep, gravityElements.TimeAtEpoch, gravityElements.Clockwise, gravityElements.Mu, gravityElements.OrbitType);

        //Calculate Eccentric Anomaly
        gravityElements.EccentricAnomaly = OrbitalHelper.calculateEccentricAnomaly(gravityElements.Eccentricity, gravityElements.SemiMajorAxis, GlobalElements.GRAV_CONST, gravityElements.TimeStep, gravityElements.TimeAtEpoch,
                                                                                   gravityElements.MeanAnomaly, gravityElements.EccentricAnomaly, gravityElements.Mu, gravityElements.Clockwise, gravityElements.OrbitType);

        //CalculateTrueAnomaly
        gravityElements.TrueAnomaly = OrbitalHelper.calculateTrueAnomaly(gravityElements.Eccentricity, gravityElements.EccentricAnomaly, gravityElements.MeanAnomaly, gravityElements.OrbitType);

        //Calculate Altitude
        gravityElements.Altitude = OrbitalHelper.calculateAltitude(gravityElements.Eccentricity, gravityElements.SemiMajorAxis, gravityElements.SemiLatusRectum, gravityElements.TrueAnomaly, gravityElements.OrbitType);

        //Calculate positionVector
        gravityElements.Position = OrbitalHelper.calculatePosition(gravityElements.Perigee, gravityElements.TrueAnomaly, gravityElements.GlobalRotationAngle, gravityElements.Altitude, gravityElements.OrbitType);

        //Are we going towards the perigee?
        gravityElements.TowardsPerigee = OrbitalHelper.towardsPerigeeOrbit(gravityElements.MeanAnomaly, gravityElements.Clockwise);

        //Calculate velocity angle
        gravityElements.VelocityAngle = OrbitalHelper.calculateVelocityAngle(gravityElements.Position, gravityElements.Eccentricity, gravityElements.SemiMajorAxis,
                                                                             gravityElements.TrueAnomaly, gravityElements.GlobalRotationAngle, gravityElements.Clockwise, gravityElements.TowardsPerigee, gravityElements.OrbitType);

        //Calculate Speed
        gravityElements.Speed = OrbitalHelper.calculateSpeed(gravityElements.Position, gravityElements.SemiMajorAxis, gravityElements.Mu, gravityElements.OrbitType);

        //Calculate Velocity
        gravityElements.velocity = OrbitalHelper.assembleVelocityVector(gravityElements.VelocityAngle, gravityElements.Speed);

        //advance epoch
        gravityElements.AnomalyAtEpoch = gravityElements.MeanAnomaly;

        //Advance time
        gravityElements.TimeAtEpoch = OrbitalHelper.advanceTime(gravityElements.TimeAtEpoch, gravityElements.TimeStep, gravityElements.Clockwise, gravityElements.OrbitType);
    }
    public void advanceToFutureState(double time)
    {
        //update timestep
        this.TimeStep = time;

        //Adjust tranformation vector
        this.GlobalTransformationVector = this.MassiveBody.transform.position;

        //Calculate next meanAnomaly
        this.MeanAnomaly = OrbitalHelper.calculateMeanAnomaly(this.Eccentricity, this.SemiMajorAxis, this.AnomalyAtEpoch,
                                                              this.TimeStep, this.TimeAtEpoch, this.Clockwise, this.Mu, this.OrbitType);

        //Calculate Eccentric Anomaly
        this.EccentricAnomaly = OrbitalHelper.calculateEccentricAnomaly(this.Eccentricity, this.SemiMajorAxis, GlobalElements.GRAV_CONST, this.TimeStep, this.TimeAtEpoch,
                                                                        this.MeanAnomaly, this.EccentricAnomaly, this.Mu, this.Clockwise, this.OrbitType);

        //CalculateTrueAnomaly
        this.TrueAnomaly = OrbitalHelper.calculateTrueAnomaly(this.Eccentricity, this.EccentricAnomaly, this.MeanAnomaly, this.OrbitType);

        //Calculate Altitude
        this.Altitude = OrbitalHelper.calculateAltitude(this.Eccentricity, this.SemiMajorAxis, this.SemiLatusRectum, this.TrueAnomaly, this.OrbitType);

        //Calculate positionVector
        this.Position = OrbitalHelper.calculatePosition(this.Perigee, this.TrueAnomaly, this.GlobalRotationAngle, this.Altitude, this.OrbitType);

        //Are we going towards the perigee?
        this.TowardsPerigee = OrbitalHelper.towardsPerigeeOrbit(this.MeanAnomaly, this.Clockwise);

        //Calculate velocity angle
        this.VelocityAngle = OrbitalHelper.calculateVelocityAngle(this.Position, this.Eccentricity, this.SemiMajorAxis,
                                                                  this.TrueAnomaly, this.GlobalRotationAngle, this.Clockwise, this.TowardsPerigee, this.OrbitType);

        //Calculate Speed
        this.Speed = OrbitalHelper.calculateSpeed(this.Position, this.SemiMajorAxis, this.Mu, this.OrbitType);

        //Calculate Velocity
        this.velocity = OrbitalHelper.assembleVelocityVector(this.VelocityAngle, this.Speed);

        //advance epoch
        this.AnomalyAtEpoch = this.MeanAnomaly;

        //Advance time
        this.TimeAtEpoch = OrbitalHelper.advanceTime(this.TimeAtEpoch, this.TimeStep, this.Clockwise, this.OrbitType);
    }
    public Tuple <Vector2, Vector2> calculateLocalPositionAndVelocityAtFutureTime(double timeStep)
    {
        //Calculate time at epoch
        double timeAtEpoch = OrbitalHelper.advanceTime(this.timeAtEpoch, timeStep, clockwise, orbitType);

        //Calculate next meanAnomaly
        double meanAnomaly = OrbitalHelper.calculateMeanAnomaly(eccentricity, semiMajorAxis, anomalyAtEpoch,
                                                                timeStep, timeAtEpoch, clockwise, mu, orbitType);

        //Calculate Eccentric Anomaly
        double eccentricAnomaly = OrbitalHelper.calculateEccentricAnomaly(eccentricity, semiMajorAxis, GlobalElements.GRAV_CONST, timeStep, timeAtEpoch,
                                                                          meanAnomaly, this.eccentricAnomaly, mu, clockwise, orbitType);

        //CalculateTrueAnomaly
        double trueAnomaly = OrbitalHelper.calculateTrueAnomaly(eccentricity, eccentricAnomaly, meanAnomaly, orbitType);

        //Calculate Altitude
        double altitude = OrbitalHelper.calculateAltitude(eccentricity, semiMajorAxis, semiLatusRectum, trueAnomaly, orbitType);

        //Calculate positionVector
        Vector2 position = OrbitalHelper.calculatePosition(perigee, trueAnomaly, globalRotationAngle, altitude, orbitType);

        //Are we going towards the perigee?
        bool towardsPerigee = OrbitalHelper.towardsPerigeeOrbit(meanAnomaly, clockwise);

        //Calculate velocity angle
        double velocityAngle = OrbitalHelper.calculateVelocityAngle(position, eccentricity, semiMajorAxis,
                                                                    trueAnomaly, globalRotationAngle, clockwise, towardsPerigee, orbitType);

        //Calculate Speed
        double speed = OrbitalHelper.calculateSpeed(position, semiMajorAxis, mu, orbitType);

        //Calculate Velocity
        Vector2 velocity = OrbitalHelper.assembleVelocityVector(velocityAngle, speed);

        //Im returning the position here, you know, just in case you couldnt figure it out on your own
        return(new Tuple <Vector2, Vector2>(position, velocity));
    }