<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Set camera looking at point without specifying heading or pitch in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/set-camera-looking-at-point-without-specifying/m-p/477847#M5885</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Morent,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All I want is to specify the camera's position , and a second point, and have the camera look straight at that second point. I curently just calculate a pitch and a heading using the haversine formula&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Esri.ArcGISRuntime.Geometry.MapPoint mapPoint1 = new Esri.ArcGISRuntime.Geometry.MapPoint(cameraLon, cameraLat, cameraAlt);
Esri.ArcGISRuntime.Geometry.MapPoint mapPoint2 = new Esri.ArcGISRuntime.Geometry.MapPoint(targetLon, targetLat, targetAlt);

//get distance
double d = distance(cameraLat, cameraLon, targetLat, targetLon, 'K') * 1000;


double t1 = deg2rad(cameraLat);
double t2 = deg2rad(targetLat);
double dt = deg2rad(targetLat - cameraLat);
double dl = deg2rad(targetLon - cameraLon);

double alt = cameraAlt - targetAlt;

double pitch = 90 - rad2deg(Math.Atan2(alt, d));

//get heading
double y = Math.Sin(dl - dt) * Math.Cos(t2);
double x = Math.Cos(t1) * Math.Sin(t2) -
&amp;nbsp; Math.Sin(t1) * Math.Cos(t2) * Math.Cos(dl - dt);
double heading = rad2deg(Math.Atan2(y, x)) + 45;

Esri.ArcGISRuntime.Controls.Camera camera = new Camera(mapPoint1, heading, pitch);

Viewpoint vp = new Viewpoint(camera, mapPoint2);

MySceneView.SetViewAsync(vp);&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to not have to calculate the heading and pitch, since this is not always accurate. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 21:06:43 GMT</pubDate>
    <dc:creator>JasonTrinidad1</dc:creator>
    <dc:date>2021-12-11T21:06:43Z</dc:date>
    <item>
      <title>Set camera looking at point without specifying heading or pitch</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/set-camera-looking-at-point-without-specifying/m-p/477845#M5883</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Is there a way to set the camera looking at a specific point in the scene without specifying a heading or pitch explicitly? I found a how to calculate pitch and heading using the haversine formula, but I was wondering if ArcGIS could do this for me. I want something similar to this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Esri.ArcGISRuntime.Geometry.MapPoint mapPoint1 = new Esri.ArcGISRuntime.Geometry.MapPoint(cameraX, cameraY, cameraAlt);
Esri.ArcGISRuntime.Geometry.MapPoint mapPoint2 = new Esri.ArcGISRuntime.Geometry.MapPoint(targetX, targetY, targetAlt);

Esri.ArcGISRuntime.Controls.Camera camera = new Camera(mapPoint1,0,0);
//or
//Esri.ArcGISRuntime.Controls.Camera camera = new Camera(mapPoint1,calculatedHeading,calculatedPitch); 
Viewpoint vp = new Viewpoint(camera, mapPoint2); //camera looks at mapPoint2

MySceneView.SetView(vp);&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:06:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/set-camera-looking-at-point-without-specifying/m-p/477845#M5883</guid>
      <dc:creator>JasonTrinidad1</dc:creator>
      <dc:date>2021-12-11T21:06:40Z</dc:date>
    </item>
    <item>
      <title>Re: Set camera looking at point without specifying heading or pitch</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/set-camera-looking-at-point-without-specifying/m-p/477846#M5884</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;A camera is defined by it's location, heading and pitch, so you will have to specify some value.&lt;/P&gt;&lt;P&gt;Is the intent to have them to be 0, or to be the same as the current values? If you want the current heading/pitch, you can use the RotateAround method to create a suitable camera:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MapPoint poi = new MapPoint(12, 56, SpatialReferences.Wgs84);&lt;/P&gt;&lt;P&gt;var currentCam = sceneView.Camera;&lt;/P&gt;&lt;P&gt;var newCamera = new Camera(poi.Y, poi.X, 1000, 0, 0); //Look straight down&lt;/P&gt;&lt;P&gt;newCamera = newCamera.RotateAround(poi, -currentCam.Heading, currentCam.Pitch);&lt;/P&gt;&lt;P&gt;sceneView.SetViewAsync(newCamera);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Aug 2015 17:44:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/set-camera-looking-at-point-without-specifying/m-p/477846#M5884</guid>
      <dc:creator>dotMorten_esri</dc:creator>
      <dc:date>2015-08-21T17:44:35Z</dc:date>
    </item>
    <item>
      <title>Re: Set camera looking at point without specifying heading or pitch</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/set-camera-looking-at-point-without-specifying/m-p/477847#M5885</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Morent,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All I want is to specify the camera's position , and a second point, and have the camera look straight at that second point. I curently just calculate a pitch and a heading using the haversine formula&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Esri.ArcGISRuntime.Geometry.MapPoint mapPoint1 = new Esri.ArcGISRuntime.Geometry.MapPoint(cameraLon, cameraLat, cameraAlt);
Esri.ArcGISRuntime.Geometry.MapPoint mapPoint2 = new Esri.ArcGISRuntime.Geometry.MapPoint(targetLon, targetLat, targetAlt);

//get distance
double d = distance(cameraLat, cameraLon, targetLat, targetLon, 'K') * 1000;


double t1 = deg2rad(cameraLat);
double t2 = deg2rad(targetLat);
double dt = deg2rad(targetLat - cameraLat);
double dl = deg2rad(targetLon - cameraLon);

double alt = cameraAlt - targetAlt;

double pitch = 90 - rad2deg(Math.Atan2(alt, d));

//get heading
double y = Math.Sin(dl - dt) * Math.Cos(t2);
double x = Math.Cos(t1) * Math.Sin(t2) -
&amp;nbsp; Math.Sin(t1) * Math.Cos(t2) * Math.Cos(dl - dt);
double heading = rad2deg(Math.Atan2(y, x)) + 45;

Esri.ArcGISRuntime.Controls.Camera camera = new Camera(mapPoint1, heading, pitch);

Viewpoint vp = new Viewpoint(camera, mapPoint2);

MySceneView.SetViewAsync(vp);&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to not have to calculate the heading and pitch, since this is not always accurate. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:06:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/set-camera-looking-at-point-without-specifying/m-p/477847#M5885</guid>
      <dc:creator>JasonTrinidad1</dc:creator>
      <dc:date>2021-12-11T21:06:43Z</dc:date>
    </item>
  </channel>
</rss>

