Vertical Plane Orientation

I am using ARKit 1.5 beta to detect vertical plane. How can I go about finding the orientation of detected vertical plane?


By orientation, I am referring to the rotational angle around y-axis, since vertical plane is paralel to gravity and perpendicular to the x-z plane.


I have tried the following method:


// point1 and point 2 are 2 points on the vertical plane I found by performing hit-test with 3d coordinates relative to the world coordinate system
let vector : SCNVector3 = point1 - point2
let projection = SCNVector3Make(vector.x, 0.0, vector.z).normalized() // project vector onto x-z plane
let xVector = SCNVector3Make(1, 0, 0)
let angle = xVector.angleBetweenVectors(projection)


func angleBetweenVectors(_ vectorB:SCNVector3) -> Float {
     let cosineAngle = (dotProduct(vectorB) / (magnitude * vectorB.magnitude))
     return Float(acos(cosineAngle))
}


This method does not give me the correct orientation. I also wonder if I can find orientation through anchor.worldTransform.

Replies

I am also looking for help with this issue. Any suggestions are appreciated. I'm able to detect vertical planes and attach nodes to them, but in the case of placing a flat object like a photo or video the plane I'm not entirely sure how to rotate/angle the node to match the detected plane.

If i understand the question, this is of interest to me as well. I am interested in being able to draw vertical lines out from map locations that are pointing straight out and "heights" set by logic within my app. This can create a pin-cushion like effect. I asked a similar question over here.