Skip to content

Instantly share code, notes, and snippets.

@slimlime
Forked from magicien/SCNQuaternion_cross.swift
Created December 17, 2018 05:53
Show Gist options
  • Save slimlime/cb9ccc1c5c8ee10764d3b344e5960f1d to your computer and use it in GitHub Desktop.
Save slimlime/cb9ccc1c5c8ee10764d3b344e5960f1d 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