Post

Replies

Boosts

Views

Activity

Reply to RoomPlan: Use the transform and dimensions to generate 4 corner points
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)
Nov ’22