"Straighten" CapturedRoom data

I'm using RoomPlan to create a 2-d layout of a room. Because it's just a single room, I want to present it 'squared' up, see my picture

First off, is there any options in the ARView that was used with the scan to sort of zero out the orientation so that it creates a room layout that is not on an angle?

If not...

Is there a well known mathematical formula to snap this to the closest 90 degrees? I tried just changing the rotation of each wall to snap to the nearest 90 degrees, but it wasn't quite good enough as they no longer joined together cleanly. Perhaps there's an algorithm for doing this while preserving the relative locations of everything?

First off, you don't want to mess with ARView...

  1. If you are making the view in 3D, do it using Scenekit and manipulating the camera to get the 2D (top-down) view.
  2. If you are wanting to provide true blueprint like view, then I would convert the wall dimensions into something simpler representation and present it using SwiftUI.

Both are doable and I have done both and combined them into one view with 2d/3d toggle.

for the most simple setup you can just calculate the smallest rotating bounding box, similar to OpenCV's rotated rect.

"Straighten" CapturedRoom data
 
 
Q