I'm trying to add the altitude the pARk sample code, so the label appears near the top of the place of interest.
The first thing I did was adding a altitude
property to PlaceOfInterest.h
and filling it on the ViewController, with the altitude for each poi being in meters.
Then, on ARView, did the following changes:
- Adding the altitude to the LLA to ECEF conversion of the device's location:
latLonToEcef(location.coordinate.latitude, location.coordinate.longitude, location.altitude, &myX, &myY, &myZ);
- same for the poi's location
latLonToEcef(poi.location.coordinate.latitude, poi.location.coordinate.longitude, poi.location.altitude, &poiX, &poiY, &poiZ);
- Added the Upwardness direction to the placesOfInterestCoordinates 4D vector
placesOfInterestCoordinates[i][2] = (float)u;
I thought that was it, pretty easy. Run the project and... labels laying dead on the floor. Comparing the label location of a poi on the app with and without my changes above, they are pretty much in the same places, even though adding the altitude the values from the conversions to ECEF and ENU should change a bit.
I had little knowledge before looking at the code about Perspective projection, all the matrixes used, ECEF, ENU, etc. And I've been reading about all these concepts in Wikipedia to be able to understand the code, plus reading other questions related to this sample code here in SO like Use of maths in the Apple pARk sample code and also similar questions for Android... but still can't figure out why the altitude doesn't show on screen.
I tried multiplying the poi's altitude by 5 latLonToEcef(location.coordinate.latitude, location.coordinate.longitude, 5*location.altitude, &myX, &myY, &myZ);
to see if there was a noticeable change on the y
position of the poi. And, while there was some, it was very small, the label still being far from the real altitude.
So if somebody could give me some hints about what am I missing, why the altitude isn't showing on screen, I'll appreciate it very much.
I uploaded my try to a repository here https://github.com/Tovkal/pARk-with-altitude, in case you want to see the code with the changes. If you run it, you should change the places of interest from the ViewController to some near you.
Thank you!