# Better way of calculating elevation angle

**URL:** <https://community.cesium.com/t/better-way-of-calculating-elevation-angle/7256>\
**Category:** CesiumJS\
**Created:** [August 5, 2018, 12:25pm UTC](https://community.cesium.com/t/better-way-of-calculating-elevation-angle/7256 "2018-08-05T12:25:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fidel\_Perez-Smith](https://avatars.discourse-cdn.com/v4/letter/f/278dde/32.png) [@Fidel\_Perez-Smith](https://community.cesium.com/u/Fidel_Perez-Smith)\
**Post date:** [August 5, 2018, 12:25pm UTC](https://community.cesium.com/t/better-way-of-calculating-elevation-angle/7256/1 "2018-08-05T12:25:00Z")

</div>

I've written some code to calculate the range, azimuth and elevation between two points.  
Sandcastle is here: [https://goo.gl/WhCP5B](https://goo.gl/WhCP5B)  
The values are printed to the console.

All the calculations work very accurately. I.e. when they are used to calculate the orientation of a cylinder, the start and end of the cylinder fall exactly on the source and target.

You'll notice though that toElevationRadiansNumerical() is not very elegant. It tries different elevation angles until it finds one that produces the expected target.

Is there a better (more concise) way to calculate the elevation angle yet still produce good results?

---

<div class="post-metadata">

**Author:** ![Gabby\_Getz](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/gabby_getz/32/7838_2.png) [@Gabby\_Getz](https://community.cesium.com/u/Gabby_Getz)\
**Post date:** [August 7, 2018, 8:57pm UTC](https://community.cesium.com/t/better-way-of-calculating-elevation-angle/7256/2 "2018-08-07T20:57:30Z")

</div>

Hi there,

While I’m no rocket scientist, after a search I found [this previous thread thread](https://groups.google.com/forum/#!searchin/cesium-dev/azimuth%7Csort:date/cesium-dev/PTpQPCQETO8/5RfLVgedpG4J). There, they suggest using the **[EllipsoidGeodesic](https://cesiumjs.org/Cesium/Build/Documentation/EllipsoidGeodesic.html)** class and in particular the **[startHeading](https://cesiumjs.org/Cesium/Build/Documentation/EllipsoidGeodesic.html?classFilter=ellipsoid#startHeading)** property.

Thanks, hopefully that helps!

Gabby

---

<div class="post-metadata">

**Author:** ![Fidel\_Perez-Smith](https://avatars.discourse-cdn.com/v4/letter/f/278dde/32.png) [@Fidel\_Perez-Smith](https://community.cesium.com/u/Fidel_Perez-Smith)\
**Post date:** [August 8, 2018, 5:52am UTC](https://community.cesium.com/t/better-way-of-calculating-elevation-angle/7256/3 "2018-08-08T05:52:18Z")

</div>

Thanks Gabby,

The bearing is calculated using EllipsoidGeodesic and startHeading. I'm looking to improve the elevation calculation.

Cheers,  
Fidel

---

<div class="post-metadata">

**Author:** ![Gabby\_Getz](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/gabby_getz/32/7838_2.png) [@Gabby\_Getz](https://community.cesium.com/u/Gabby_Getz)\
**Post date:** [August 9, 2018, 5:52pm UTC](https://community.cesium.com/t/better-way-of-calculating-elevation-angle/7256/4 "2018-08-09T17:52:10Z")

</div>

Sorry, I missed that! Like I said, I’m not familiar with the algorithms used here. I would try reaching out to the community members in that thread as they are likely more versed in this.
