All problems
Quaternion Conjugate
Problem
Return the conjugate of the quaternion q = [w, x, y, z], which negates the vector part:
conj(q) = [w, -x, -y, -z]
Hint
For unit quaternions the conjugate is the inverse rotation.
Test cases
case 1
in: [[1,2,3,4]]
expected: [1,-2,-3,-4]
case 2
in: [[0,0,0,0]]
expected: [0,0,0,0]
case 3
in: [[1.5,-2.5,3.5,-4.5]]
expected: [1.5,2.5,-3.5,4.5]
case 4
in: [[2,0,0,0]]
expected: [2,0,0,0]
Starter codePython
def quaternion_conjugate(q):
# Your code here
pass4 test cases · run your code against them in the editor