RoomPlan: Use the transform and dimensions to generate 4 corner points

I'm trying to use data returned from the RoomCaptureSession delegate to draw four corners of a door in SceneKit.

The CapturedRoom.Surface class has Dimensions and Transform members.

I was told in the WWDC 2022 RoomPlan Slack lounge:

"You can use transform and dimensions parameters to draw lines. The 4 corners can be inferred from those 2 parameters: the first column of the transform is the "right" vector, and second is the "up" vector. The fourth column is the position of the wall/door/opening/window/object Combining those unit vectors with the dimensions vector will give you the corners."

So I think this is a basic vector question. I'm not sure what is meant by "Combining those unit vectors with the dimensions vector". I've tried a few things, but I'm not sure how to go about this.

Answered by mike.normal13 in 717009022

So this is how I pulled something of kind of quick and dirty.

The dimensions vector is [width, height, length]

And the central point of the door can be defined as: Point(door.transform[3].x, door.transform[3].y, door.transform[3].z) 

I'm seeing the length come up as zero for doors. 

So I defined the upper left point as: 

upperLeftPoint = Point(centerPoint) 
upperLeftPoint = upperLeftPoint.translate(rightV.negate(), doorWidth/2) 
upperLeftPoint = upperLeftPoint.translate(upV, doorHeight/2)

I found it

Accepted Answer

So this is how I pulled something of kind of quick and dirty.

The dimensions vector is [width, height, length]

And the central point of the door can be defined as: Point(door.transform[3].x, door.transform[3].y, door.transform[3].z) 

I'm seeing the length come up as zero for doors. 

So I defined the upper left point as: 

upperLeftPoint = Point(centerPoint) 
upperLeftPoint = upperLeftPoint.translate(rightV.negate(), doorWidth/2) 
upperLeftPoint = upperLeftPoint.translate(upV, doorHeight/2)

Can you please post the solution

Hi, below is code to extract four corner points of wall from its dimensions and transform matrix.

center = transform[3]
rightVector = transform[0]
upVector = transform[1]

angle = atan2f(dimensions.y/2, dimensions.x/2)

diagonalDistance = sqrt(dimensions.x/2 * dimensions.x/2 + dimensions.y/2 * dimensions.y/2)

move =  CGPoint(x: diagonalDistance * cos(angle), y: diagonalDistance * sin(angle))

topLeftPoint = center.translate(x: rightVector.x * move.x + upVector.x * move.y, 
                                y: rightVector.y * move.x + upVector.y * move.y, 
                                z: rightVector.z * move.x + upVector.z * move.y)
RoomPlan: Use the transform and dimensions to generate 4 corner points
 
 
Q