Distinguishing Between Horizontal and Vertical ARRaycastResults when using .any

I am using ARView.raycast to find out information about a given estimatedPlane in front of the camera, and I want to treat horizontal results differently than vertical.

It seems that when using .any in the alignment argument, a lot of the results returned are .any (not .horizontal or .vertical), and very few are explicitly horizontal or vertical. Conversely, if I raycast for just one alignment, I get plenty of results in the alignment I request, so I think many of those .any results are being inferred to a .horizontal or .vertical result when you don't use the .any alignment option.

So what is the best way for me to do that same kind of inference on .any results so that I can categorize them by horizontal and vertical alignments? I see there is a worldTransform, and I also see that when I print the description of the result I get something like this:

<ARRaycastResult: 0x281598370 target=estimatedPlane worldTransform=<translation=(-0.176499 -0.960197 -1.208480) rotation=(90.00° 0.00° -3.60°)>>

So under the hood the description is converting the quaternion into Euler degrees. Is there a built-in function to do this? The one I have tried does not return results that line up with the raycast result description values.

The world transform you get from ARRaycastResult is a simd_float4x4. We don't have a way in RealityKit to turn a float4x4 to euler angles but you should be able to do that with ModelIO.MDLTransform: https://developer.apple.com/documentation/modelio/mdltransform/1391642-rotation

In the meanwhile, you can also check the targetAlignment property of the ARRaycastResult.

Thanks very much--the MDLTransform looks like just what I want! But the targetAlignment property is actually the problem: when using .any raycasts, most of the results you get back are .any targetAlignments which isn't particularly useful in my situation since I'm trying to distinguish between horizontal and vertical alignments.

Distinguishing Between Horizontal and Vertical ARRaycastResults when using .any
 
 
Q