Beispiel #1
0
    public Vector2 calculatePositionAtFutureTime(double timeStep)
    {
        //Adjust tranformation vector
        Vector2 globalTransformationVector = gravityElements.MassiveBody.transform.position;

        //Calculate time at epoch
        double timeAtEpoch = OrbitalHelper.advanceTime(gravityElements.TimeAtEpoch, timeStep, gravityElements.Clockwise, gravityElements.OrbitType);

        //Calculate next meanAnomaly
        double meanAnomaly = OrbitalHelper.calculateMeanAnomaly(gravityElements.Eccentricity, gravityElements.SemiMajorAxis, gravityElements.AnomalyAtEpoch,
                                                                timeStep, timeAtEpoch, gravityElements.Clockwise, gravityElements.Mu, gravityElements.OrbitType);

        //Calculate Eccentric Anomaly
        double eccentricAnomaly = OrbitalHelper.calculateEccentricAnomaly(gravityElements.Eccentricity, gravityElements.SemiMajorAxis, GlobalElements.GRAV_CONST, timeStep, timeAtEpoch,
                                                                          meanAnomaly, gravityElements.EccentricAnomaly, gravityElements.Mu, gravityElements.Clockwise, gravityElements.OrbitType);

        //CalculateTrueAnomaly
        double trueAnomaly = OrbitalHelper.calculateTrueAnomaly(gravityElements.Eccentricity, eccentricAnomaly, meanAnomaly, gravityElements.OrbitType);

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

        //Calculate positionVector
        Vector2 position = OrbitalHelper.calculatePosition(gravityElements.Perigee, trueAnomaly, gravityElements.GlobalRotationAngle, altitude, gravityElements.OrbitType);

        //Im returning the position here, you know, just in case you couldnt figure it out on your own
        return(position);
    }
    //This behavior is shared by all gravity bound objects
    public Vector2 calculateLocalPositionAtFutureTime(double timeStep)
    {
        //Adjust tranformation vector
        Vector2 globalTransformationVector = massiveBody.transform.position;

        //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);

        return(position);
    }
Beispiel #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));
    }