// private func lineBetweenNodeA(beginPosition: SCNVector3, endPosition: SCNVector3) -> SCNNode { // let positions: [Float32] = [beginPosition.x, beginPosition.y, beginPosition.z, endPosition.x, endPosition.y, endPosition.z] // let positionData = NSData(bytes: positions, length: MemoryLayout<Float32>.size*positions.count) // let indices: [Int32] = [0, 1] // let indexData = NSData(bytes: indices, length: MemoryLayout<Int32>.size * indices.count) // let source = SCNGeometrySource(data: positionData as Data, semantic: SCNGeometrySource.Semantic.vertex, vectorCount: indices.count, usesFloatComponents: true, componentsPerVector: 3, bytesPerComponent: MemoryLayout<Float32>.size, dataOffset: 0, dataStride: MemoryLayout<Float32>.size * 3) // let element = SCNGeometryElement(data: indexData as Data, primitiveType: SCNGeometryPrimitiveType.line, primitiveCount: indices.count, bytesPerIndex: MemoryLayout<Int32>.size) // glLineWidth(10) // let line = SCNGeometry(sources: [source], elements: [element]) // return SCNNode(geometry: line) // } // // func distance(startPosition:SCNVector3,endPosition:SCNVector3) -> CGFloat{ // let x1 = startPosition.x // let y1 = startPosition.y // let z1 = startPosition.z // let x2 = endPosition.x // let y2 = endPosition.y // let z2 = endPosition.z // let r = sqrt(pow(x2-x1, 2) pow(y2-y1, 2) pow(z1-z2, 2)) // return CGFloat(r) // }
// func calculateRotationY(beginPosition:SCNVector3,endPosition:SCNVector3) -> Float{ // var θ:Float = 0.0 // let x = endPosition.x // let z = endPosition.z // if z > 0 && x > 0{ // θ = atan(z/x) // }else if z > 0 && x < 0 { // θ = atan(z/x) Float.pi // }else if z < 0 && x > 0{ // θ = 2*Float.pi atan(z/x) // }else if z < 0 && x < 0{ // θ = Float.pi atan(z/x) // }else if x == 0 { // if z > 0 { // θ = 0 // }else if z < 0 { // θ = Float.pi // }else if z == 0 { // θ = 0 // } // } // return θ // }