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?
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
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…
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?
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…
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.