SceneKit-绘制直线

// 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 θ
// }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值