Skip to content

Instantly share code, notes, and snippets.

@magicien
Created December 31, 2017 06:08
Show Gist options
  • Save magicien/75a7a667b39c609fa1010fca20516312 to your computer and use it in GitHub Desktop.
Save magicien/75a7a667b39c609fa1010fca20516312 to your computer and use it in GitHub Desktop.
public func Cross(_ q1: SCNQuaternion, _ q2: SCNQuaternion) -> SCNQuaternion {
return SCNQuaternion(
q1.w * q2.x + q1.x * q2.w + q1.y * q2.z - q1.z * q2.y,
q1.w * q2.y - q1.x * q2.z + q1.y * q2.w + q1.z * q2.x,
q1.w * q2.z + q1.x * q2.y - q1.y * q2.x + q1.z * q2.w,
q1.w * q2.w - q1.x * q2.x - q1.y * q2.y - q1.z * q2.z
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment