Select to view content in your preferred language

Runtime camera and bearing strange behaviour

2190
2
11-19-2015 06:57 AM
Durga_PrasadD
Deactivated User

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=generateBearing(x, y, x[i + 1], y[i + 1]);

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

                 _animationViewpoints.Add(new Camera(new MapPoint(x, y, 50), heading, 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, 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());

            }

        }

0 Kudos
2 Replies
EricBader
Honored Contributor

Hi Durga,

In a previous life I was a .NET programmer, and this code looks very familiar!

Have you also posted this question to our .NET forum? This one here is specific to Android.

Thanks!

0 Kudos
AnttiKajanus1
Deactivated User

Could you provide a bit more details and/or full reproducible application to demonstrate the issue?

0 Kudos