1

There are two coordinate system, one is geo (global), and one is local (just for that floor in the building). I have logged all four corners on that floor in both coordinate systems. The problem for conversion is that they don't have aligned X with long and Y with Lat. How they look I tried to sketch: https://cl.ly/3Z3b280b0L14

Note: We can ignore spherical part of the geo coordinate system because error will be small on floor level.

Any hint how to do a translation?

dormitkon
  • 111

1 Answers1

1

If you’re working with a pair of rectangles, finding an affine transformation that maps one to the other is fairly simple. The same procedure that’s used here to find a transformation between aligned rectangles will work for your situation as well.

Pick three corresponding pairs of corners, so that you’ve got $(x_1,y_1)\leftrightarrows(\text{lat}_1,\text{long}_1)$ and so on. To find the matrix that maps from local to global coordinates, write the homogeneous coordinates of the three destination corners as the columns of one matrix, and the three source corners in the same order as the columns of another matrix. Invert the second (source) matrix and multiply them together, like so: $$M=\pmatrix{\text{lat}_1&\text{lat}_2&\text{lat}_3\\\text{long}_1&\text{long}_2&\text{long}_3\\1&1&1}\pmatrix{x_1&x_2&x_3\\y_1&y_2&y_3\\1&1&1}^{-1}.$$ To convert any point from local to global coordinates, all you have to do is multiply the homogeneous coordinates of the point by $M$, i.e., $(\text{lat},\text{long},1)^T=M(x,y,1)^T$. The matrix $M$ will have a row of $1$s along the bottom, so effectively, this transformation amounts to $$\begin{align}\text{lat}&=m_{11}x+m_{12}y+m_{13} \\ \text{long}&=m_{21}x+m_{22}y+m_{23}\end{align}$$ where $m_{ij}$ is the element in the $i$th row and $j$th column of $M$. To map from global to local, just use the inverse matrix $M^{-1}$.

This method will also work if you have a pair of parallelograms instead of rectangles. If you don’t need a lot of accuracy, you should be able to tweak the corners of the source and destination regions so that you have the required parallelograms. If the two regions are more general quadrilaterals, then it’s still possible to map between them, but you’ll need a planar perspective transformation. You can find a description of how to construct such a transformation from a pair of quadrilaterals here.

If this is to be part of a piece of software that you’re writing, I recommend investigating the graphics libraries that you might have available to you. Many of them have built-in functions for building the types of transformations that you’re looking for.

amd
  • 53,693