@@ -137,13 +137,6 @@ PMQuaternionTest >> testHash [
137137 self assert: 1 k k hash equals: - 1 hash
138138]
139139
140- { #category : #running }
141- PMQuaternionTest >> testLn [
142- | eps |
143- eps := 1.0e-6 .
144- self assert: ((1 + 2 i) ln - (1 + 2 j k) ln) abs < eps
145- ]
146-
147140{ #category : #running }
148141PMQuaternionTest >> testLog [
149142
@@ -160,6 +153,67 @@ PMQuaternionTest >> testLog [
160153 self assert: (qln qk closeTo: qlg10ln qk)
161154]
162155
156+ { #category : #running }
157+ PMQuaternionTest >> testNaturalLogOfQuaternion [
158+
159+ " See https://en.wikipedia.org/wiki/Quaternion#cite_note-Särkkä2007-39 for more detail"
160+
161+ | quaternion naturalLogOfQuaternion expected vectorPartOfQuaternion |
162+ quaternion := 3 + 4 i + 5 j + 6 k.
163+ naturalLogOfQuaternion := quaternion ln.
164+
165+ vectorPartOfQuaternion := PMQuaternion
166+ qr: 0
167+ qi: 4
168+ qj: 5
169+ qk: 6 .
170+ expected := 86 sqrt ln
171+ + (vectorPartOfQuaternion / 77 sqrt * (3 / 86 sqrt) arcCos).
172+
173+ self assert: naturalLogOfQuaternion qr equals: expected qr.
174+ self assert: naturalLogOfQuaternion qi equals: expected qi.
175+ self assert: naturalLogOfQuaternion qj closeTo: expected qj.
176+ self assert: naturalLogOfQuaternion qk equals: expected qk
177+ ]
178+
179+ { #category : #running }
180+ PMQuaternionTest >> testNaturalLogOfQuaternionWithNoVectorPart [
181+ | expected naturalLogOfQuaternion quaternionWithNoVector |
182+
183+ quaternionWithNoVector := 5 + 0 i + 0 j + 0 k.
184+
185+ naturalLogOfQuaternion := quaternionWithNoVector ln.
186+
187+ expected := 5 ln + 0 i + 0 j + 0 k.
188+ self assert: naturalLogOfQuaternion qr equals: expected qr.
189+ self assert: naturalLogOfQuaternion qi equals: 0 .
190+ self assert: naturalLogOfQuaternion qj equals: 0 .
191+ self assert: naturalLogOfQuaternion qk equals: 0 .
192+ ]
193+
194+ { #category : #tests }
195+ PMQuaternionTest >> testNaturalLogOfQuaternionWithOnlyVectorPart [
196+
197+ " See https://en.wikipedia.org/wiki/Quaternion#cite_note-Särkkä2007-39 for more detail"
198+
199+ | quaternion naturalLogOfQuaternion expected expectedVectorPart |
200+ quaternion := 0 + 7 i - 10 j + 23 k.
201+ naturalLogOfQuaternion := quaternion ln.
202+ expectedVectorPart := PMQuaternion
203+ qr: 0
204+ qi: 7
205+ qj: - 10
206+ qk: 23 .
207+
208+
209+ expected := 678 sqrt ln + ((expectedVectorPart / 678 sqrt) * ((0 / 678 sqrt) arcCos)).
210+
211+ self assert: naturalLogOfQuaternion qr equals: expected qr.
212+ self assert: naturalLogOfQuaternion qi equals: expected qi.
213+ self assert: naturalLogOfQuaternion qj closeTo: expected qj.
214+ self assert: naturalLogOfQuaternion qk equals: expected qk
215+ ]
216+
163217{ #category : #running }
164218PMQuaternionTest >> testOne [
165219 self assert: PMQuaternion one unreal isZero.
@@ -264,6 +318,15 @@ PMQuaternionTest >> testSinh [
264318 self assert: ((1 + 2 i) sinh - (1 + 2 j k) sinh) abs < eps
265319]
266320
321+ { #category : #running }
322+ PMQuaternionTest >> testSquareOfQuaternion [
323+ | q expected |
324+ q := 1 + 2 i - 3 j - 4 k.
325+ expected := - 28 + 4 i - 6 j - 8 k.
326+
327+ self assert: q squared equals: expected
328+ ]
329+
267330{ #category : #running }
268331PMQuaternionTest >> testSubtractPolynomial [
269332 | poly |
0 commit comments