Tuesday, 28 January 2014

Slightly Better AR Microlocation Algorithm

There are two parts to Augmented Reality: knowing which way you're looking around you, and knowing where you are. I've started the first one, in one axis at least. I've also started the second, by jumping right up to the nearest object.

As I showed in that article, it's a bit rough: if the nearest object is the light, I only see the light, up close, without a surrounding place. Only if no beacon is near do I see the place the light is in, with that light and any other lights.

While waiting for the mathematical energy and inspiration to tackle proper trilateration, what I actually want is for the 3D AR view to always be in the place that the surrounding objects or Things occupy, rather than jumping off to the object alone.

Then when I move in to a beacon on a Thing, for the user object or avatar in that place, and their 3D view, to also move smoothly closer to the 3D representation of the Thing object within that place.

Tricky Algorithm

Now, it's not tested, but here's the algorithm I worked out on the train today:

  If the nearest object is a place:
    If already in that place:
      If looking up close at an object:
        initiate zoom to the middle of the place
      jump to the middle of the place
    If already in the place the object is in:
      If not already looking at the object:
        initiate zoom up to the object
      jump to the middle of the place
      initiate zoom up to the object

Way more complex than I ever imagined! And that's not even close to a trilateration algorithm.

The action "jump to the middle of the place" is resetting the 3D view to a new place URL and putting the user in the middle, of the room, etc. Arbitrary, but on average not a bad choice, I hope.

By "initiate zoom..", I mean kick off a thread to move the user's avatar smoothly to a target destination position in the place. Since at this point I only have the URL of the target object, I also need to look up its position coordinates from the place it's in, or the coordinates of the middle of the place.

On top of that, for zooming up to an object, I need to stop before I hit its actual position. So I need to get its bounding box and turn that into a bounding circle radius, so that I can stop zooming that far back.

Only two weeks to go to the end of this ThoughtWorks exercise..

No comments:

Post a Comment