Skip to content

Instantly share code, notes, and snippets.

@arjo129
Created December 10, 2017 10:55
Show Gist options
  • Save arjo129/fbd5d72e53bc93e2235622ea2e3d006d to your computer and use it in GitHub Desktop.
Save arjo129/fbd5d72e53bc93e2235622ea2e3d006d to your computer and use it in GitHub Desktop.
Just the conjugation... It doesnt work correctly still
def conjugation(self, vector):
"""Conjugation of vector by self.
@param self unit quaternion.
@param vector 3-vector, aka pure quaternion.
@return pure quaternion of result: self *vector*self.
"""
self.x,self.y,self.z = self.v
Q = np.array([[self.w, -self.z, self.y, self.x],
[ self.z, self.w, -self.x, self.y],
[-self.y, self.x, self.w, self.z],
[-self.x,-self.y,-self.z,self.w]])
Q_star = np.array([[self.w, -self.z, self.y, -self.x],
[ self.z, self.w, -self.x, -self.y],
[-self.y, self.x, self.w, -self.z],
[self.x,self.y,self.z,self.w]])
return np.matmul(np.matmul(Q,Q_star),[*vector,0])[:3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment