AnsweredAssumed Answered

Runtime camera and bearing strange behaviour

Question asked by ddurgaprasad on Nov 19, 2015
Latest reply on Nov 26, 2015 by akajanus-esristaff

I find strange behavior with below implementation in Scene examples.The movement appears to have unexpected heading changes along the path.I have a set of points which are perfectly interpolated and are working fine in 2D animation.

 

public double generateBearing(double ox, double oy, double dx, double dy)

        {

            double bearing = 0.0;

            double lon1 = ToRad(ox);

            double lat1 = ToRad(oy);

            double lon2 = ToRad(dx);

            double lat2 = ToRad(dy);

            double dLon = lon2 - lon1;

            double y = Math.Sin(dLon) * Math.Cos(lat2);

            double x = Math.Cos(lat1) * Math.Sin(lat2) - Math.Sin(lat1) * Math.Cos(lat2) * Math.Cos(dLon);

            double bRad = Math.Atan2(y, x);

            double tmpB = ToDegrees(bRad);

            //bearing =360.0-(tmpB+270.0)%360.0;

            bearing = tmpB;

            return bearing;

        }

 

  private void CreateAnimationViewpoints()

        {

            _animationViewpoints = new List<Camera>();

 

            Array.Reverse(x);

            Array.Reverse(y);

 

            heading = new double[nPointCount];

 

            for (int i = 0; i < nPointCount-1; i++)

            {

                 heading[i]=generateBearing(x[i], y[i], x[i + 1], y[i + 1]);

               // heading[i] = getBearing(x[i], y[i], x[i + 1], y[i + 1]);

                 _animationViewpoints.Add(new Camera(new MapPoint(x[i], y[i], 50), heading[i], 70));                

                              

            }

           

        }

private async void MySceneView_SpatialReferenceChanged(object sender, System.EventArgs e)

        {

            MySceneView.SpatialReferenceChanged -= MySceneView_SpatialReferenceChanged;

 

            try

            {

                for (int i = 0; i < nPointCount; i++)

                {

 

                    await MySceneView.SetViewAsync(_animationViewpoints[i], 1, false);

              

                }

                // Set navigation in the order we want to animate the camera

               

 

            }

            catch (Exception ex)

            {

                MessageBox.Show("Error occured while navigating to the target viewpoint",

                    "An error occured");

                Debug.WriteLine(ex.ToString());

            }

        }

Outcomes