Coordinates translation and rotation for geolocalization

36 Views Asked by At

I am working on an app to do the following task: project a floor plan on the ground using gps location.

In detail: suppose I have a floor plan of a building. I know nothing about it: neither size, nor geographic orientation.

All I can ask the user is a set of 2 (or three, probably) locations: of these two points I know the geographic location (long/lat) and their exact position on the floor plan. In other words, I can know that point (x,y) on the floor plan has geographic coordinates (a,b), I can know this twice.

From these 2 single points I should be able to "geolocalize" the floor plan, a part from measurement error, and create a translation function to couple any point on the floor plan in a biunique way with its geographic coordinate and vice-versa: from a geographic point determine what position on the floor plan is.

I created quickly this function thinking it was easy and suddenly I realized it was completely wrong: I was not taking into consideration two important facts:

  1. The floor plan can be rotated by any degree, I must use the floor plan proportions to understand not only the size and position, but also the orientation of the floor plan.

  2. The geographic coordinates are not constant and one longitude degree depends on what latitude we're at. This means that to understand rotation of the floor plan we also have to consider this particular fact.

What I am looking for is some help for my poor brain that is starting to smoke :) I cannot cope with all these information, including the fact that everything must be squeezed depending on the latitude, and this creates to me an additional layer of confusion.

As soon as anyway "projecting" a rigid image on a map is something that actually has already been largely studied and developped, I am here to ask if there is a formula or an algorithm that does all this or can help me.

Thank you very much.