Beispiel #1
0
        //Interprets a given AbsoluteVector as a velocity, and returns the corresponding Vector3d velocity
        //in world coordinates.
        public Vector3d WorldVelocityAtCurrentTime(AbsoluteVector absolute)
        {
            double now = Planetarium.GetUniversalTime();
            double unrotatedLongitude = MuUtils.ClampDegrees360(absolute.longitude - 360 * (now - absolute.UT) / referenceBody.rotationPeriod);

            return(absolute.radius * referenceBody.GetSurfaceNVector(absolute.latitude, unrotatedLongitude));
        }
Beispiel #2
0
        //Vector3d must be either a position RELATIVE to referenceBody, or a velocity
        public AbsoluteVector ToAbsolute(Vector3d vector3d, double UT)
        {
            AbsoluteVector absolute = new AbsoluteVector();

            absolute.latitude = 180 / Math.PI * Math.Asin(Vector3d.Dot(vector3d.normalized, lat90AtStart));

            double longitude = 180 / Math.PI * Math.Atan2(Vector3d.Dot(vector3d.normalized, lat0lon90AtStart), Vector3d.Dot(vector3d.normalized, lat0lon0AtStart));

            longitude         -= 360 * (UT - epoch) / referenceBody.rotationPeriod;
            absolute.longitude = MuUtils.ClampDegrees180(longitude);

            absolute.radius = vector3d.magnitude;

            absolute.UT = UT;

            return(absolute);
        }
Beispiel #3
0
            public List <Vector3d> WorldTrajectory(double timeStep, bool world = true)
            {
                if (!trajectory.Any())
                {
                    return(new List <Vector3d>());
                }

                List <Vector3d> ret = new List <Vector3d>();

                if (world)
                {
                    ret.Add(referenceFrame.WorldPositionAtCurrentTime(trajectory[0]));
                }
                else
                {
                    ret.Add(referenceFrame.BodyPositionAtCurrentTime(trajectory[0]));
                }
                double lastTime = trajectory[0].UT;

                for (int i = 0; i < trajectory.Count; i++)
                {
                    AbsoluteVector absolute = trajectory[i];
                    if (absolute.UT > lastTime + timeStep)
                    {
                        if (world)
                        {
                            ret.Add(referenceFrame.WorldPositionAtCurrentTime(absolute));
                        }
                        else
                        {
                            ret.Add(referenceFrame.BodyPositionAtCurrentTime(absolute));
                        }
                        lastTime = absolute.UT;
                    }
                }
                return(ret);
            }
Beispiel #4
0
 //Interprets a given AbsoluteVector as a velocity, and returns the corresponding Vector3d velocity
 //in world coordinates.
 public Vector3d WorldVelocityAtCurrentTime(AbsoluteVector absolute)
 {
     double now = Planetarium.GetUniversalTime();
     double unrotatedLongitude = MuUtils.ClampDegrees360(absolute.longitude - 360 * (now - absolute.UT) / referenceBody.rotationPeriod);
     return absolute.radius * referenceBody.GetSurfaceNVector(absolute.latitude, unrotatedLongitude);
 }
Beispiel #5
0
 //Interprets a given AbsoluteVector as a position, and returns the corresponding Vector3d position
 //in world coordinates.
 public Vector3d WorldPositionAtCurrentTime(AbsoluteVector absolute)
 {
     return referenceBody.position + WorldVelocityAtCurrentTime(absolute);
 }
Beispiel #6
0
        //Vector3d must be either a position RELATIVE to referenceBody, or a velocity
        public AbsoluteVector ToAbsolute(Vector3d vector3d, double UT)
        {
            AbsoluteVector absolute = new AbsoluteVector();

            absolute.latitude = 180 / Math.PI * Math.Asin(Vector3d.Dot(vector3d.normalized, lat90AtStart));

            double longitude = 180 / Math.PI * Math.Atan2(Vector3d.Dot(vector3d.normalized, lat0lon90AtStart), Vector3d.Dot(vector3d.normalized, lat0lon0AtStart));
            longitude -= 360 * (UT - epoch) / referenceBody.rotationPeriod;
            absolute.longitude = MuUtils.ClampDegrees180(longitude);

            absolute.radius = vector3d.magnitude;

            absolute.UT = UT;

            return absolute;
        }
 public Vector3d BodyPositionAtCurrentTime(AbsoluteVector absolute)
 {
     return referenceBody.position + absolute.radius * referenceBody.GetSurfaceNVector(absolute.latitude, absolute.longitude);
 }
Beispiel #8
0
 //Interprets a given AbsoluteVector as a position, and returns the corresponding Vector3d position
 //in world coordinates.
 public Vector3d WorldPositionAtCurrentTime(AbsoluteVector absolute)
 {
     return(referenceBody.position + WorldVelocityAtCurrentTime(absolute));
 }
Beispiel #9
0
 public Vector3d BodyPositionAtCurrentTime(AbsoluteVector absolute)
 {
     return(referenceBody.position + absolute.radius * referenceBody.GetSurfaceNVector(absolute.latitude, absolute.longitude));
 }