Search code examples
iosswift3dios16

Calculate area using simd_float3


Im using the new RoomPlanner API from iOS 16, and the idea is to calculate every wall area in meters, or at least the widht and height. Is there a way o calculate that using the object

CapturedRoom.Walls ?

Heres the object that im supposed to use;

https://developer.apple.com/documentation/accelerate/simd_float3


Solution

  • Just iterate through CapturedRoom.Walls.

    let walls = capturedRoom.walls
    var totalWallArea: Float = 0
    for wall in walls {
        let wallArea = wall.plane.width * wall.plane.height
        totalWallArea += wallArea
    }
    print("Total wall area: \(totalWallArea) square meters")