Give a standard fitting method a perfect walk, with no noise in it at all, and ask how far a floor plan is turned from north. The true answer was 57.3°. The method said 30.9°.
That result came from checking iseeido’s on-site calibration against made-up walks. Nothing was wrong with the data. The method assumed something that isn’t true of a scan.
Two records of one walk
A scan knows its own shape but not where it is. Its origin is wherever the scan started, and its directions come from whichever way the phone faced at the start. To place it on Earth, iseeido needs two numbers: where the scan’s zero point sits on the planet, and the bearing of the scan’s X axis.
If you are at the building, you can find both on foot. Once the room is recognised, you start recording and walk. At each location reading, iseeido notes where the scan says you are and where the reading says you are on Earth. That gives two records of the same walk, one in the scan’s metres and one in metres east and north.
Centre both records and position drops out. The size is already known, because a scan is measured in metres. Only the turn is left. So the obvious tool is a rotation: turn one record until it lies on the other.
The scan’s axes turn the other way
Look down on a scan with its Y axis pointing up at you. Going from X to Z is a quarter turn clockwise. On a map, going from east to north is a quarter turn anticlockwise.
Turn X onto east and Z points south. Turn Z onto north and X points west. So the step from a scan’s numbers to the Earth’s isn’t a rotation at all. It’s a reflection: the matrix that does it has a determinant of minus 1.
The cause is dropping the height. The scan’s 3D frame is right-handed, and taking Y away to get a flat floor flips the handedness of what’s left. The building isn’t mirrored. The way its numbers are written down is.
- 57.3°the true turn in the check, on data with no noise
- 30.9°what a rotation-only fit returned for it
Why a clean walk gives no warning
A rotation can’t do what a reflection does. It can only find the nearest compromise, and that depends on the shape of the walk.
Take the simplest walk there is, a dead straight line. A straight line is the same line in a mirror, so a rotation can lay one record exactly on the other with nothing left over. By its own measure the fit is perfect. But it has matched the line and nothing else, and everything either side of the line lands on the wrong side.
That reasoning was worked out for this post. iseeido’s notes give the two angles but not the shape of the walk behind them. The drawing is one walk that produces them: a straight line 13.2° off the scan’s X axis. Point the same walk another way and the rotation gives another answer, while the truth stays at 57.3°.
What iseeido does instead
iseeido’s fit only considers reflections, the one family of answers that can be true of a scan. Within that family the best turn comes straight from a formula. There’s nothing to iterate, and every reading counts.
A reflection is also its own inverse. So the sum that takes a scan’s point to the Earth brings an Earth point back again, as the same expression with its arguments swapped. Lining a plan up on the satellite map needs no fit at all: the plan is drawn with X up and Z to the right, and you turn it yourself.
For the person holding the phone
None of this appears on the screen. It decides where things land. A door you mark is stored in the scan’s own coordinates, and this same transform turns it into the point on Earth that the street route heads for. It runs the other way too: until the camera has recognised the room, your location is drawn on the plan through it. On a mirrored plan, a door on the south wall could be sent somewhere else entirely, from a fit that looked clean.
Getting the family right removes the mirror. It doesn’t remove the noise in location readings. That’s still why the screen says “The further you walk, the better the north alignment”, and won’t attempt a fit until you’ve walked at least 8 metres.
The sums, and how far to walk
- From scan to Earth, where θ is the bearing of the scan’s X axis:
east = x sin θ + z cos θandnorth = x cos θ - z sin θ. - The fit, on centred records:
θ = atan2(S, C), withS = Σ(e·x - n·z)andC = Σ(e·z + n·x). - For this post: a rotation-only fit of a straight walk at angle α from X, measured towards Z, returns θ + 2α. So 57.3° with α of -13.2° gives 30.9°.
- Median north error from simulated walks with 5 metres of location noise: 22.9° after 5 metres of walking, 16.2° after 8, 8.0° after 15, 4.2° after 30 and 2.1° after 60.