Post Reply 
(12C) Quaternion Multiplication on the HP-12C
06-21-2019, 06:37 PM
Post: #1
(12C) Quaternion Multiplication on the HP-12C
I know little about quaternions but they have become somewhat in vogue for computer graphics as they represent a more computationally efficient approach in that field for 3-D rotational calculations. They were discovered (invented?) by an Irish mathematician who memorialized them by becoming Dublin's first graffiti artist! Actually, his original graffiti is long gone but replaced by a plaque commemorating his discovery at that spot and their fundamental identity (i^2=j^2=k^2=i*j*k=-1) which he had scratched onto the bridge at the Royal Canal in his moment of inspiration in 1843. Where a complex number is an ordered pair of real numbers, a quaternion is an ordered quadruplet of real numbers. Unlike complex numbers, quaternion multiplication is not commutative. Hyper complex numbers don't stop there - octonions are ordered octuplets of real numbers etc.

Anyhow, I thought the calculation of the product of two quaternions might fit into a HP-12C and gave it a go. It hasn't been done before, I presume, and it's nice to be first at something - anything! Below is the program - just in case you ever have to multiply two quaternions.... Tongue

Code:

// Quaternion multiplication for the HP-12C
// Written by J. Henry, Dublin June 2019
//
// Run program and enter first quaternion n,i,j,k when 
// prompted and then second one in same order.
// The quaternion product is stored in n,i,PV,PMT

01 0
02 STO n
03 9
04 STO 0
05 1            // ::1 Input quaternions loop
06 STO-0
07 RCL 0
08 x=0?
09 g GTO 16        // goto ::2 compute product
10 9
11 X/Y
12 -
13 R/S
14 g CFj
15 g GTO 05    // goto ::1 continue inputting 
16 0                // ::2 compute quaternion product
17 n
18 RCL 1
19 RCL 5
20 *
21 RCL 2
22 RCL 6
23 *
24 -
25 RCL 3
26 RCL 7
27 *
28 -
29 RCL 4
30 RCL 8
31 *
32 -
33 STO n        // real part of quaternion product stored in [n]
34 RCL 1
35 RCL 6
36 *
37 RCL 2
38 RCL 5
39 *
40 +
41 RCL 3
42 RCL 8
43 *
44 +
45 RCL 4
46 RCL 7
47 *
48 -
49 STO i        // i component stored in [i] where else?!
50 RCL 1
51 RCL 7
52 *
53 RCL 2
54 RCL 8
55 *
56 -
57 RCL 3
58 RCL 5
59 *
60 +
61 RCL 4
62 RCL 6
63 *
64 +
65 STO PV        // j component stored in [PV]
66 RCL 1
67 RCL 8
68 *
69 RCL 2
70 RCL 7
71 *
72 -
73 RCL 3
74 RCL 6
75 *
76 -
77 RCL 4
78 RCL 5
79 *
80 +
81 STO PMT        // k component stored in [PMT]
82 RCL n        // display real part on completion
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(12C) Quaternion Multiplication on the HP-12C - Joe_H - 06-21-2019 06:37 PM



User(s) browsing this thread: 1 Guest(s)