Dear visitors and members, with the staff having moved on to other life interests and as a result of changes in people's internet usage habits, the CodeWalrus community have migrated almost entirely to Discord, IRC and WalrusIRC and is now essentially a place where to hang out, chat about gaming, programming, music, anime, and chill. As a result, even though the CW forums will remain open for posting, for faster TI, Casio or HP calculator help and news we recommend using the bilingual TI-Planet forums instead.

### WalrusIRC

You need to have 5 posts and not be part of restricted usergroups in order to use the WalrusIRC embedded shoutbox. However, you can also access our IRC channel called #CodeWalrus via EFnet.

### Author Topic: Quaternion Arithmetic Program  (Read 946 times)

0 Members and 1 Guest are viewing this topic.

#### Thecoder1998

• New User
• Join Date: Dec 2014
• Location: Not sure
• Posts: 15
• Post Rating Ratio: +0/-0
##### Quaternion Arithmetic Program
« on: April 18, 2015, 04:41:58 pm »
Hi guys, i'm currently learning how to program in Python and i've made a neat little script which can do arithmetic with quaternions
Code: [Select]
`from numpy import matrixdef quaternion(a,b,c,d):    u = matrix('1.,0.,0.,0.;0.,1.,0.,0.;0.,0.,1.,0.;0.,0.,0.,1.')    i = matrix('0.,1.,0.,0.;-1.,0.,0.,0.;0.,0.,0.,-1.;0.,0.,1.,0.')    j = matrix('0.,0.,1.,0.;0.,0.,0.,1.;-1.,0.,0.,0.;0.,-1.,0.,0.')    k = matrix('0.,0.,0.,1.;0.,0.,-1.,0.;0.,1.,0.,0.;-1.,0.,0.,0.')    q = a*u+b*i+c*j+d*k    return qdef printquaternion(q):    a = q.item(0,0)    b = q.item(0,1)    c = q.item(0,2)    d = q.item(0,3)    q = "%s+%si+%sj+%sk"%(a,b,c,d)    print q`here is a screenshot

« Last Edit: April 18, 2015, 04:43:58 pm by Thecoder1998 »

#### Snektron

• Lvl 69 Russian Snake
• Super User
• Join Date: Dec 2014
• Location: Netherlands
• Posts: 3165
• Post Rating Ratio: +32/-0
• SSSssssss.....
• Gender:
##### Re: Quaternion Arithmetic Program
« Reply #1 on: April 18, 2015, 08:40:13 pm »
Maybe you could make it parse a quaterion from a string too, that would be cool
• Calculators owned: TI-84+
Legends say if you spam more than DJ Omnimaga, you will become a walrus...

#### Duke "Tape" Eiyeron

• Urist McEiyolobster
• Super User
• Join Date: Nov 2014
• Location: (V)(-_(//));(V)
• Posts: 1636
• Post Rating Ratio: +11/-2
• Fanciest Walrus of the oceans.
• Gender:
##### Re: Quaternion Arithmetic Program
« Reply #2 on: April 20, 2015, 04:19:32 pm »
I forgot how it's nice to print formatted strings on python as in C but easier.
• Calculators owned: A lot.

You can also use the following HTML or bulletin board code to share it on your page or forum signature!

Also do not forget to check our affiliates below.