title: how to find centre of a plane found in a hit test ARKit SceneKit
body: <p>In an image detection app, the image is recognised, then an opaque overlay plane is created so when the user taps on the screen a hit test finds the overlay plane, and a new object can be created. But I want to position the object exactly at the centre of the underlying image. How can I get it to be always at the centre of the image / plane, and to have the same orientation. Can this be got from a hit test result? Thanks for any advice!</p>
  
  <pre><code>@objc func handleScreenTap(sender: UITapGestureRecognizer) {
    let tappedSceneView = sender.view as! ARSCNView
    let tapLocation = sender.location(in: tappedSceneView)
  
    let planeIntersections = tappedSceneView.hitTest(tapLocation, types: [.estimatedHorizontalPlane, .estimatedVerticalPlane])
    if !planeIntersections.isEmpty {
      addSceneAtPositionOnPlane(hitTestResult: planeIntersections.first!)
  }
  
  func addSceneAtPositionOnPlane(hitTestResult: ARHitTestResult) {
  
    let transform = hitTestResult.worldTransform
    let positionColumn = transform.columns.3
    let initialPosition = SCNVector3(positionColumn.x,
                                   positionColumn.y,
                                   positionColumn.z)
  
     let node = self.createScene(for: initialPosition)
     sceneView.scene.rootNode.addChildNode(node)
  }
  
  func createScene(for position: SCNVector3) -&gt; SCNNode {
  
    let box = SCNNode(geometry: SCNBox(width: 0.1, //x
                                      height: 0.1, //y
                                      length: 0.1, //z
                                      chamferRadius: 0))
  
    box.geometry?.firstMaterial?.diffuse.contents = UIColor.red
    box.geometry?.firstMaterial?.isDoubleSided = true
    box.opacity = 0.8
  
    box.position = position        
    return box
  }
  </code></pre>