Quaternion Norm

325 days ago by sweetser

r""" q_norm - taking the norm of a quaternion. The norm is the size. In spacetime, the size is time, not a spatial length. Clocks determine magnitued. AUTHORS: -- Doug Sweetser (2009): Initial version. EXAMPLES: Test the various conjugates. sage: q1 = q(1, 2, 3, 4) sage: q(30,0,0,0)==q1.norm() True """ #***************************************************************************** # Copyright (C) 2009 Doug Sweetser <sweetser@alum.mit.edu> # # Distributed under the terms of the GNU General Public License (GPL) # http://www.gnu.org/licenses/ #***************************************************************************** 
       
class q(list): def __init__(self,t,x,y,z): self.t = t self.x = x self.y = y self.z = z self.qn = [] list.__init__(self,[t,x,y,z]) def __repr__(self): return "Quaternion norm." def show(self): print self.t, self.x, self.y, self.z def add_n(self, q1, n): self.qn[:] = [] for i in range (0, n): t = self.t + i * q1.t x = self.x + i * q1.x y = self.y + i * q1.y z = self.z + i * q1.z self.qn.append(q(t, x, y, z)) return q(t, x, y, z) def norm(self): return q(self.t * self.t + self.x * self.x + self.y * self.y + self.z * self.z, 0, 0, 0) #auto 
       
q1 = q(1, 2, 3, 4) q(30,0,0,0)==q1.norm() 
       
True
q2 = q(.1, .1, .1, .1); q1.add_n(q2,11); for r in q1.qn: r.norm().show() 
       
30.0000000000000 0 0 0
32.0400000000000 0 0 0
34.1600000000000 0 0 0
36.3600000000000 0 0 0
38.6400000000000 0 0 0
41.0000000000000 0 0 0
43.4400000000000 0 0 0
45.9600000000000 0 0 0
48.5600000000000 0 0 0
51.2400000000000 0 0 0
54.0000000000000 0 0 0
r""" Conclusion: the norm takes from the real and 3 imaginaries, returning only the real. For events in spacetime, that means the norm is only about time. A large norm indicates a long amount of time. Time is money in spacetime. """