# Elevation Angle

**URL:** <https://community.cesium.com/t/elevation-angle/428>\
**Category:** CesiumJS\
**Created:** [April 26, 2013, 12:42pm UTC](https://community.cesium.com/t/elevation-angle/428 "2013-04-26T12:42:07Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tobias\_Reinicke](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@Tobias\_Reinicke](https://community.cesium.com/u/Tobias_Reinicke)\
**Post date:** [April 26, 2013, 12:42pm UTC](https://community.cesium.com/t/elevation-angle/428/1 "2013-04-26T12:42:07Z")

</div>

Hi all,

Quick one - I want to calculate the angle between a point on the ground and a point with a positive z value that is moving around the earth. (Javascript, not czml).

I can see that there is a Cartesian3.angleBetween - but I’m not sure what this returns. On what plane is this angle? x / y / z?

Thanks.

Toby

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [April 26, 2013, 12:56pm UTC](https://community.cesium.com/t/elevation-angle/428/2 "2013-04-26T12:56:42Z")

</div>

Hi Toby,

Cartesian3.angleBetween returns the smallest angle between the vectors. In other words, it’s the angle in a plane that contains both vectors.

If you want the angle in a particular plane, use a dot product to project your vectors into the desired plane before using angleBetween.

Kevin

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [April 26, 2013, 1:17pm UTC](https://community.cesium.com/t/elevation-angle/428/3 "2013-04-26T13:17:23Z")

</div>

Sorry, my brain is not entirely engaged yet this morning. Projecting a vector into a general plane takes a bit more than a dot product, of course. If your plane of interest is aligned with two of the axes (for example, the X-Y plane), then you can project just by setting the third coordinate to zero (Z in this example). For a general plane, see here: [http://stackoverflow.com/questions/9605556/how-to-project-a-3d-point-to-a-3d-plane](http://stackoverflow.com/questions/9605556/how-to-project-a-3d-point-to-a-3d-plane)

---

<div class="post-metadata">

**Author:** ![Tobias\_Reinicke](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@Tobias\_Reinicke](https://community.cesium.com/u/Tobias_Reinicke)\
**Post date:** [April 26, 2013, 1:57pm UTC](https://community.cesium.com/t/elevation-angle/428/4 "2013-04-26T13:57:33Z")

</div>

Thanks for that Kevin.

So if I have two cartesians - and I need to calculate the elevation angle - I thought I could just use normal maths (asin (hyp/adj). But that isn’t working. probably because I’m not respecting some laws of 3dness…

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [April 26, 2013, 2:02pm UTC](https://community.cesium.com/t/elevation-angle/428/5 "2013-04-26T14:02:35Z")

</div>

First you need to define what plane you want the elevation angle “out of”, and either choose your axes or reproject as necessary. But after that, regular trig identities should work. Let’s see if my brain is engaged yet: sin theta = opposite / hypotenuse, right?

---

<div class="post-metadata">

**Author:** ![Tobias\_Reinicke](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@Tobias\_Reinicke](https://community.cesium.com/u/Tobias_Reinicke)\
**Post date:** [April 26, 2013, 2:04pm UTC](https://community.cesium.com/t/elevation-angle/428/6 "2013-04-26T14:04:57Z")

</div>

Indeed! (sohcahtoa right?)

Ok, so happy with the second part of that - but not entirely sure how I chose my axes… or reproject accordingly. Still trying to get my head around 3d space… bear with me…

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [April 26, 2013, 2:15pm UTC](https://community.cesium.com/t/elevation-angle/428/7 "2013-04-26T14:15:49Z")

</div>

If you’re interested in the elevation angle as observed by a point on the ground, your plane of interest is probably the local horizontal plane. In other words, a plane with a normal parallel to the WGS84 ellipsoid surface normal. This plane isn’t exactly the same as what a level would show you at that point on the Earth, but it’s very close.

To transform your target point in the Earth-fixed frame to this local horizontal plane, you can use Transforms.eastNorthUpToFixedFrame. That returns a Matrix4, which you then multiply your target point vector by, yielding a new vector. Normalize that vector, and then the elevation angle is simply asin(z) of the normalized vector.

---

<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:** [June 14, 2017, 2:57am UTC](https://community.cesium.com/t/elevation-angle/428/8 "2017-06-14T02:57:07Z")

</div>

Hi Toby, Kevin,

Do you have a working sample for doing this? I’ve had a go and have put my code on stackoverflow:

> <https://stackoverflow.com/questions/44534634/calculate-elevation-angle-between-two-lat-long-alt-points-using-cesiumjs>

Thank you,

Fidel
