1

In which swift library i will get cross product funtion

like cross(normalize(vector1),normalize(vector2))

i want angle direction between three scnnode joint with line

let node0 :SCNNode = self.nodes[1]
let node1 :SCNNode = self.nodes[2]
let node2 :SCNNode = self.nodes[3]
let vector1 = float3((node0.position.x - node1.position.x), (node0.position.y - node1.position.y), (node0.position.z - node1.position.z))
let vector2 = float3((node2.position.x - node1.position.x), (node2.position.y - node1.position.y), (node2.position.z - node1.position.z))
let dotProduct = dot(normalize(vector1), normalize(vector2))
let theta = acos(dotProduct)

This is my sample code and theta is and radian angle between those point and is perfect but how to get angle direction is my question

Yogesh Dalavi
  • 73
  • 4
  • 15
  • Is your question about the cross product or about the (directed) angle between vectors? For the latter, see https://stackoverflow.com/questions/28641096/calculating-angle-between-two-points-on-edge-of-circle-swift-spritekit. – Martin R Aug 30 '18 at 06:55
  • I want the angle direction whether it is positive or negative from the base center point – Yogesh Dalavi Aug 30 '18 at 06:59

1 Answers1

1

You can import simd library so that you will get cross product function

import simd
let crossp = cross(normalize(vector1), normalize(vector2))
let dotpOfcross  = dot(crossp,float3.init(node0.position))

I think this is what you want as per your question please check and let here know.

Rohan Pawar
  • 1,875
  • 22
  • 40