ARKit Tracking and Visualizing Planes - Angle between ARPlaneAnchor and local gravitational plane?

I've been looking for a way to find the actual "dihedral" angle between a plane (ARPlaneAnchor) and the local gravitational plane. Think "calculating the grade of a wheelchair ramp (i.e. its slope) using data from an iPhone."

I realize that this is very roughly provided in the alignment member of an ARPlaneAchor, as either .horizontal or .vertical, but what about planes in between? Presumably ARKit is using this angle to classify a plane as horizonal or vertical.

Is there an easy way to access the raw data, or to otherwise access that infomation?

I have also looked at the "CaptureSample" example, in which I can get a gravity vector using CoreMotion, but there's no obvious way to correlate what's in a scene with gravity.

Hi Dave,

ARKit only detects planes that are either perpendicular or parallel to gravity, so an ARPlane's alignment will always either be .horizontal or .vertical. For surfaces that are neither horizontally or vertically aligned, you can check out the scene reconstruction API (check out https://developer.apple.com/documentation/arkit/content_anchors/visualizing_and_interacting_with_a_reconstructed_scene). This API provides you with a 3D mesh representing the planar and non-planar surfaces of the environment, which you could also use to calculate the angle of a slanted surface such a wheelchair ramp.

It feels like we're really close! There seems to be a bit of confusion in what the .normals property of an ARGeometryElement represents. The documentation says they are the "Rays that define which direction is outside for each face" but for any ARGeometryElement, the .normals.count is equal to .vertices.count and NOT .faces.count. (To be fair, the comment in ARKit.ARMeshGeometry for normals says "Normal of each vertex in the mesh.")

What I'm interested in of course is the normal to any given face. Is there an easy way to get the normal vector of a face, as defined by an ARGeometryElement?

We have access to the (three) vertices defining each face, so I guess it's just a bit vector math?

How about to try framework FindSurface?

The source codes of app examples are available:

FindSurface-SceneKit-ARDemo-iOS (Swift)

FindSurface-GUIDemo-iOS (Swift)

ARKit Tracking and Visualizing Planes - Angle between ARPlaneAnchor and local gravitational plane?
 
 
Q