summaryrefslogtreecommitdiff
path: root/indra/llmath/tests/llquaternion_test.cpp
blob: e69010b2d63e17f6121343e674381cc81e3925d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
/** 
 * @file llquaternion_test.cpp
 * @author Adroit
 * @date 2007-03
 * @brief Test cases of llquaternion.h
 *
 * $LicenseInfo:firstyear=2007&license=viewerlgpl$
 * Second Life Viewer Source Code
 * Copyright (C) 2010, Linden Research, Inc.
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation;
 * version 2.1 of the License only.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * 
 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 * $/LicenseInfo$
 */

#include "linden_common.h"
#include "../test/lltut.h"

#include "../v4math.h"
#include "../v3math.h"
#include "../v3dmath.h"
#include "../m4math.h"
#include "../m3math.h"
#include "../llquaternion.h"

namespace tut
{
	struct llquat_test
	{
	};
	typedef test_group<llquat_test> llquat_test_t;
	typedef llquat_test_t::object llquat_test_object_t;
	tut::llquat_test_t tut_llquat_test("LLQuaternion");

	//test case for LLQuaternion::LLQuaternion(void) fn.
	template<> template<>
	void llquat_test_object_t::test<1>()
	{
		LLQuaternion llquat;
		ensure("LLQuaternion::LLQuaternion() failed", 0.f == llquat.mQ[0] &&
		 									0.f == llquat.mQ[1] &&
		 									0.f == llquat.mQ[2] &&
											1.f == llquat.mQ[3]);
	}

	//test case for explicit LLQuaternion(const LLMatrix4 &mat) fn.
	template<> template<>
	void llquat_test_object_t::test<2>()
	{
		LLMatrix4 llmat;
		LLVector4 vector1(2.0f, 1.0f, 3.0f, 6.0f);
		LLVector4 vector2(5.0f, 6.0f, 0.0f, 1.0f);
		LLVector4 vector3(2.0f, 1.0f, 2.0f, 9.0f);
		LLVector4 vector4(3.0f, 8.0f, 1.0f, 5.0f);

		llmat.initRows(vector1, vector2, vector3, vector4);
		ensure("explicit LLQuaternion(const LLMatrix4 &mat) failed", 2.0f == llmat.mMatrix[0][0] &&
										 	1.0f == llmat.mMatrix[0][1] &&
											3.0f == llmat.mMatrix[0][2] &&
											6.0f == llmat.mMatrix[0][3] &&
											5.0f == llmat.mMatrix[1][0] &&
											6.0f == llmat.mMatrix[1][1] &&
											0.0f == llmat.mMatrix[1][2] &&
											1.0f == llmat.mMatrix[1][3] &&
											2.0f == llmat.mMatrix[2][0] &&
											1.0f == llmat.mMatrix[2][1] &&
											2.0f == llmat.mMatrix[2][2] &&
											9.0f == llmat.mMatrix[2][3] &&
											3.0f == llmat.mMatrix[3][0] &&
											8.0f == llmat.mMatrix[3][1] &&
											1.0f == llmat.mMatrix[3][2] &&
											5.0f == llmat.mMatrix[3][3]);
	}
	
	template<> template<>
	void llquat_test_object_t::test<3>()
	{
		LLMatrix3 llmat;

		LLVector3 vect1(3.4028234660000000f , 234.56f, 4234.442234f);
		LLVector3 vect2(741.434f, 23.00034f, 6567.223423f);
		LLVector3 vect3(566.003034f, 12.98705f, 234.764423f);
		llmat.setRows(vect1, vect2, vect3);

		ensure("LLMatrix3::setRows fn failed.", 3.4028234660000000f == llmat.mMatrix[0][0] &&
										234.56f == llmat.mMatrix[0][1] &&
										4234.442234f == llmat.mMatrix[0][2] &&
										741.434f == llmat.mMatrix[1][0] &&
										23.00034f == llmat.mMatrix[1][1] &&
										6567.223423f == llmat.mMatrix[1][2] &&
										566.003034f == llmat.mMatrix[2][0] &&
										12.98705f == llmat.mMatrix[2][1] &&
										234.764423f == llmat.mMatrix[2][2]);		
	}

	//test case for LLQuaternion(F32 x, F32 y, F32 z, F32 w), setQuatInit() and normQuat() fns.
	template<> template<>
	void llquat_test_object_t::test<4>()
	{
		F32 x_val = 3.0f;
		F32 y_val = 2.0f;
		F32 z_val = 6.0f;
		F32 w_val = 1.0f;
		
		LLQuaternion res_quat;
		res_quat.setQuatInit(x_val, y_val, z_val, w_val);
		res_quat.normQuat();
				
		ensure("LLQuaternion::normQuat() fn failed", 
							is_approx_equal(0.42426407f, res_quat.mQ[0]) &&
							is_approx_equal(0.28284273f, res_quat.mQ[1]) &&
							is_approx_equal(0.84852815f, res_quat.mQ[2]) &&
							is_approx_equal(0.14142136f, res_quat.mQ[3]));
		
		x_val = 0.0f;
		y_val = 0.0f;
		z_val = 0.0f;
		w_val = 0.0f;

		res_quat.setQuatInit(x_val, y_val, z_val, w_val);
		res_quat.normQuat();

		ensure("LLQuaternion::normQuat() fn. failed.", 
							is_approx_equal(0.0f, res_quat.mQ[0]) &&
							is_approx_equal(0.0f, res_quat.mQ[1]) &&
							is_approx_equal(0.0f, res_quat.mQ[2]) &&
							is_approx_equal(1.0f, res_quat.mQ[3]));


		ensure("LLQuaternion::normQuat() fn. failed.", 
							is_approx_equal(0.0f, res_quat.mQ[0]) &&
							is_approx_equal(0.0f, res_quat.mQ[1]) &&
							is_approx_equal(0.0f, res_quat.mQ[2]) &&
							is_approx_equal(1.0f, res_quat.mQ[3]));
	}

	//test case for conjQuat() and transQuat() fns.
	template<> template<>
	void llquat_test_object_t::test<5>()
	{
		F32 x_val = 3.0f;
		F32 y_val = 2.0f;
		F32 z_val = 6.0f;
		F32 w_val = 1.0f;
		
		LLQuaternion res_quat;
		LLQuaternion result, result1;
		result1 = result = res_quat.setQuatInit(x_val, y_val, z_val, w_val);
				
		result.conjQuat();
		result1.transQuat();

		ensure("LLQuaternion::conjQuat and LLQuaternion::transQuat failed ", 
								is_approx_equal(result1.mQ[0], result.mQ[0]) &&
								is_approx_equal(result1.mQ[1], result.mQ[1]) &&
								is_approx_equal(result1.mQ[2], result.mQ[2]));		

	}

	//test case for dot(const LLQuaternion &a, const LLQuaternion &b) fn.
	template<> template<>
	void llquat_test_object_t::test<6>()
	{
		LLQuaternion quat1(3.0f, 2.0f, 6.0f, 0.0f), quat2(1.0f, 1.0f, 1.0f, 1.0f);
		ensure("1. The two values are different", llround(12.000000f, 2) == llround(dot(quat1, quat2), 2));

		LLQuaternion quat0(3.0f, 9.334f, 34.5f, 23.0f), quat(34.5f, 23.23f, 2.0f, 45.5f);
		ensure("2. The two values are different", llround(1435.828807f, 2) == llround(dot(quat0, quat), 2));
	}

	//test case for LLQuaternion &LLQuaternion::constrain(F32 radians) fn.
	template<> template<>
	void llquat_test_object_t::test<7>()
	{
		F32 radian = 60.0f;
		LLQuaternion quat(3.0f, 2.0f, 6.0f, 0.0f);
		LLQuaternion quat1;
		quat1 = quat.constrain(radian);
		ensure("1. LLQuaternion::constrain(F32 radians) failed", 
									is_approx_equal_fraction(-0.423442f, quat1.mQ[0], 8) &&
									is_approx_equal_fraction(-0.282295f, quat1.mQ[1], 8) &&
									is_approx_equal_fraction(-0.846884f, quat1.mQ[2], 8) &&				
									is_approx_equal_fraction(0.154251f, quat1.mQ[3], 8));				
											

		radian = 30.0f;
		LLQuaternion quat0(37.50f, 12.0f, 86.023f, 40.32f);
		quat1 = quat0.constrain(radian);
	
		ensure("2. LLQuaternion::constrain(F32 radians) failed", 
									is_approx_equal_fraction(37.500000f, quat1.mQ[0], 8) &&
									is_approx_equal_fraction(12.0000f, quat1.mQ[1], 8) &&
									is_approx_equal_fraction(86.0230f, quat1.mQ[2], 8) &&				
									is_approx_equal_fraction(40.320000f, quat1.mQ[3], 8));				
	}

	template<> template<>
	void llquat_test_object_t::test<8>()
	{
		F32 value1 = 15.0f;
		LLQuaternion quat1(1.0f, 2.0f, 4.0f, 1.0f);
		LLQuaternion quat2(4.0f, 3.0f, 6.5f, 9.7f);
		LLQuaternion res_lerp, res_slerp, res_nlerp;
		
		//test case for lerp(F32 t, const LLQuaternion &q) fn. 
		res_lerp = lerp(value1, quat1);
		ensure("1. LLQuaternion lerp(F32 t, const LLQuaternion &q) failed", 
										is_approx_equal_fraction(0.181355f, res_lerp.mQ[0], 16) &&
										is_approx_equal_fraction(0.362711f, res_lerp.mQ[1], 16) &&
										is_approx_equal_fraction(0.725423f, res_lerp.mQ[2], 16) &&				
										is_approx_equal_fraction(0.556158f, res_lerp.mQ[3], 16));				

		//test case for lerp(F32 t, const LLQuaternion &p, const LLQuaternion &q) fn.
		res_lerp = lerp(value1, quat1, quat2);
		ensure("2. LLQuaternion lerp(F32 t, const LLQuaternion &p, const LLQuaternion &q) failed",
										is_approx_equal_fraction(0.314306f, res_lerp.mQ[0], 16) &&
										is_approx_equal_fraction(0.116156f, res_lerp.mQ[1], 16) &&
										is_approx_equal_fraction(0.283559f, res_lerp.mQ[2], 16) &&				
										is_approx_equal_fraction(0.898506f, res_lerp.mQ[3], 16));				

		//test case for slerp( F32 u, const LLQuaternion &a, const LLQuaternion &b ) fn.
		res_slerp = slerp(value1, quat1, quat2);
		ensure("3. LLQuaternion slerp( F32 u, const LLQuaternion &a, const LLQuaternion &b) failed", 
										is_approx_equal_fraction(46.000f, res_slerp.mQ[0], 16) &&
										is_approx_equal_fraction(17.00f, res_slerp.mQ[1], 16) &&
										is_approx_equal_fraction(41.5f, res_slerp.mQ[2], 16) &&				
										is_approx_equal_fraction(131.5f, res_slerp.mQ[3], 16));				

		//test case for nlerp(F32 t, const LLQuaternion &a, const LLQuaternion &b) fn.
		res_nlerp = nlerp(value1, quat1, quat2);
		ensure("4. LLQuaternion nlerp(F32 t, const LLQuaternion &a, const LLQuaternion &b) failed",  
										is_approx_equal_fraction(0.314306f, res_nlerp.mQ[0], 16) &&
										is_approx_equal_fraction(0.116157f, res_nlerp.mQ[1], 16) &&
										is_approx_equal_fraction(0.283559f, res_nlerp.mQ[2], 16) &&				
										is_approx_equal_fraction(0.898506f, res_nlerp.mQ[3], 16));				

		//test case for nlerp(F32 t, const LLQuaternion &q) fn.
		res_slerp = slerp(value1, quat1);
		ensure("5. LLQuaternion slerp(F32 t, const LLQuaternion &q) failed", 
										is_approx_equal_fraction(1.0f, res_slerp.mQ[0], 16) &&
										is_approx_equal_fraction(2.0f, res_slerp.mQ[1], 16) &&
										is_approx_equal_fraction(4.0000f, res_slerp.mQ[2], 16) &&				
										is_approx_equal_fraction(1.000f, res_slerp.mQ[3], 16));				
										
		LLQuaternion quat3(2.0f, 1.0f, 5.5f, 10.5f);
		LLQuaternion res_nlerp1;
		value1 = 100.0f;
		res_nlerp1 = nlerp(value1, quat3);
		ensure("6. LLQuaternion nlerp(F32 t, const LLQuaternion &q)  failed", 
										is_approx_equal_fraction(0.268245f, res_nlerp1.mQ[0], 16) &&										is_approx_equal_fraction(0.134122f, res_nlerp1.mQ[1], 2) &&
										is_approx_equal_fraction(0.737673f, res_nlerp1.mQ[2], 16) &&				
										is_approx_equal_fraction(0.604892f, res_nlerp1.mQ[3], 16));				

		//test case for lerp(F32 t, const LLQuaternion &q) fn. 
		res_lerp = lerp(value1, quat2);
		ensure("7. LLQuaternion lerp(F32 t, const LLQuaternion &q) failed", 
										is_approx_equal_fraction(0.404867f, res_lerp.mQ[0], 16) &&
										is_approx_equal_fraction(0.303650f, res_lerp.mQ[1], 16) &&
										is_approx_equal_fraction(0.657909f, res_lerp.mQ[2], 16) &&				
										is_approx_equal_fraction(0.557704f, res_lerp.mQ[3], 16));				
		
	}

	template<> template<>
	void llquat_test_object_t::test<9>()
	{
		//test case for LLQuaternion operator*(const LLQuaternion &a, const LLQuaternion &b) fn
		LLQuaternion quat1(1.0f, 2.5f, 3.5f, 5.5f);
		LLQuaternion quat2(4.0f, 3.0f, 5.0f, 1.0f);
		LLQuaternion result = quat1 *  quat2;
		ensure("1. LLQuaternion Operator* failed", (21.0f == result.mQ[0]) &&
											(10.0f == result.mQ[1]) &&
											(38.0f == result.mQ[2]) && 
											(-23.5f == result.mQ[3]));

		LLQuaternion quat3(2341.340f, 2352.345f, 233.25f, 7645.5f);
		LLQuaternion quat4(674.067f, 893.0897f, 578.0f, 231.0f);
		result = quat3 * quat4;
		ensure("2. LLQuaternion Operator* failed", (4543086.5f == result.mQ[0]) &&
											(8567578.0f == result.mQ[1]) &&
											(3967591.25f == result.mQ[2]) &&
											is_approx_equal(-2047783.25f, result.mQ[3]));

		//inline LLQuaternion operator+(const LLQuaternion &a, const LLQuaternion &b)fn.		
		result = quat1 + quat2;
		ensure("3. LLQuaternion operator+ failed", (5.0f == result.mQ[0]) &&
											(5.5f == result.mQ[1]) &&
											(8.5f == result.mQ[2]) &&
											(6.5f == result.mQ[3]));

		result = quat3 + quat4;
		ensure(
			"4. LLQuaternion operator+ failed",
			is_approx_equal(3015.407227f, result.mQ[0]) &&
			is_approx_equal(3245.434570f, result.mQ[1]) &&
			(811.25f == result.mQ[2]) &&
			(7876.5f == result.mQ[3]));

		//inline LLQuaternion operator-(const LLQuaternion &a, const LLQuaternion &b) fn
		result = quat1 - quat2;
		ensure(
			"5. LLQuaternion operator-(const LLQuaternion &a, const LLQuaternion &b) failed", 
			(-3.0f == result.mQ[0]) &&
			(-0.5f == result.mQ[1]) &&
			(-1.5f == result.mQ[2]) &&
			(4.5f == result.mQ[3]));

		result = quat3 - quat4;
		ensure(
			"6. LLQuaternion operator-(const LLQuaternion &a, const LLQuaternion &b) failed", 
			is_approx_equal(1667.273071f, result.mQ[0]) &&
			is_approx_equal(1459.255249f, result.mQ[1]) &&
			(-344.75f == result.mQ[2]) &&
			(7414.50f == result.mQ[3]));
	}

	//test case for LLVector4 operator*(const LLVector4 &a, const LLQuaternion &rot) fn.
	template<> template<>
	void llquat_test_object_t::test<10>()
	{
		LLVector4 vect(12.0f, 5.0f, 60.0f, 75.1f);
		LLQuaternion quat(2323.034f, 23.5f, 673.23f, 57667.5f);
		LLVector4 result = vect * quat;
		ensure(
			"1. LLVector4 operator*(const LLVector4 &a, const LLQuaternion &rot) failed", 
			is_approx_equal(39928406016.0f, result.mV[0]) &&
			// gcc on x86 actually gives us more precision than we were expecting, verified with -ffloat-store - we forgive this
			(1457802240.0f >= result.mV[1]) && // gcc+x86+linux
			(1457800960.0f <= result.mV[1]) && // elsewhere
			is_approx_equal(200580612096.0f, result.mV[2]) &&
			(75.099998f == result.mV[3]));

		LLVector4 vect1(22.0f, 45.0f, 40.0f, 78.1f);
		LLQuaternion quat1(2.034f, 45.5f, 37.23f, 7.5f);
		result = vect1 * quat1;
		ensure(
			"2. LLVector4 operator*(const LLVector4 &a, const LLQuaternion &rot) failed", 
			is_approx_equal(-58153.5390f, result.mV[0]) &&
			(183787.8125f == result.mV[1]) &&
			(116864.164063f == result.mV[2]) &&
			(78.099998f == result.mV[3]));
	}

	//test case for LLVector3 operator*(const LLVector3 &a, const LLQuaternion &rot) fn.
	template<> template<>
	void llquat_test_object_t::test<11>()
	{
		LLVector3 vect(12.0f, 5.0f, 60.0f);
		LLQuaternion quat(23.5f, 6.5f, 3.23f, 56.5f);
		LLVector3 result = vect * quat;
		ensure(
			"1. LLVector3 operator*(const LLVector3 &a, const LLQuaternion &rot) failed", 
			is_approx_equal(97182.953125f,result.mV[0]) &&
			is_approx_equal(-135405.640625f, result.mV[1]) &&
			is_approx_equal(162986.140f, result.mV[2]));

		LLVector3 vect1(5.0f, 40.0f, 78.1f);
		LLQuaternion quat1(2.034f, 45.5f, 37.23f, 7.5f);
		result = vect1 * quat1;
		ensure(
			"2. LLVector3 operator*(const LLVector3 &a, const LLQuaternion &rot) failed", 
			is_approx_equal(33217.703f, result.mV[0]) &&
			is_approx_equal(295383.8125f, result.mV[1]) &&
			is_approx_equal(84718.140f, result.mV[2]));
	}

	//test case for LLVector3d operator*(const LLVector3d &a, const LLQuaternion &rot) fn.
	template<> template<>
	void llquat_test_object_t::test<12>()
	{
		LLVector3d vect(-2.0f, 5.0f, -6.0f);
		LLQuaternion quat(-3.5f, 4.5f, 3.5f, 6.5f);
		LLVector3d result = vect * quat;
		ensure(
			"1. LLVector3d operator*(const LLVector3d &a, const LLQuaternion &rot) failed ", 
			(-633.0f == result.mdV[0]) &&
			(-300.0f == result.mdV[1]) &&
			(-36.0f == result.mdV[2]));

		LLVector3d vect1(5.0f, -4.5f, 8.21f);
		LLQuaternion quat1(2.0f, 4.5f, -7.2f, 9.5f);
		result = vect1 * quat1;
		ensure(
			"2. LLVector3d operator*(const LLVector3d &a, const LLQuaternion &rot) failed", 
			is_approx_equal_fraction(-120.29f, (F32) result.mdV[0], 8) &&
			is_approx_equal_fraction(-1683.958f, (F32) result.mdV[1], 8) &&
			is_approx_equal_fraction(516.56f, (F32) result.mdV[2], 8));

		LLVector3d vect2(2.0f, 3.5f, 1.1f);
		LLQuaternion quat2(1.0f, 4.0f, 2.0f, 5.0f);
		result = vect2 * quat2;
		ensure(
			"3. LLVector3d operator*(const LLVector3d &a, const LLQuaternion &rot) failed", 
			is_approx_equal_fraction(18.400001f, (F32) result.mdV[0], 8) &&
			is_approx_equal_fraction(188.6f, (F32) result.mdV[1], 8) &&
			is_approx_equal_fraction(32.20f, (F32) result.mdV[2], 8));
	}

	//test case for inline LLQuaternion operator-(const LLQuaternion &a) fn.
	template<> template<>
	void llquat_test_object_t::test<13>()
	{
		LLQuaternion quat(23.5f, 34.5f, 16723.4f, 324.7f);
		LLQuaternion result = -quat;
		ensure(
			"1. LLQuaternion operator-(const LLQuaternion &a) failed", 
			(-23.5f == result.mQ[0]) &&
			(-34.5f == result.mQ[1]) &&
			(-16723.4f == result.mQ[2]) &&
			(-324.7f == result.mQ[3]));

		LLQuaternion quat1(-3.5f, -34.5f, -16.4f, -154.7f);
		result = -quat1;
		ensure(
			"2. LLQuaternion operator-(const LLQuaternion &a) failed.", 
			(3.5f == result.mQ[0]) &&
			(34.5f == result.mQ[1]) &&
			(16.4f == result.mQ[2]) &&
			(154.7f == result.mQ[3]));
	}

	//test case for inline LLQuaternion operator*(F32 a, const LLQuaternion &q) and
	//inline LLQuaternion operator*(F32 a, const LLQuaternion &q) fns.
	template<> template<>
	void llquat_test_object_t::test<14>()
	{
		LLQuaternion quat_value(9.0f, 8.0f, 7.0f, 6.0f);
		F32 a =3.5f;
		LLQuaternion result = a * quat_value;
		LLQuaternion result1 = quat_value * a;

		ensure(
			"1. LLQuaternion operator* failed",
			(result.mQ[0] == result1.mQ[0]) &&
			(result.mQ[1] == result1.mQ[1]) &&
			(result.mQ[2] == result1.mQ[2]) &&
			(result.mQ[3] == result1.mQ[3]));


		LLQuaternion quat_val(9454.0f, 43568.3450f, 456343247.0343f, 2346.03434f);
		a =-3324.3445f;
		result = a * quat_val;
		result1 = quat_val * a;

		ensure(
			"2. LLQuaternion operator* failed",
			(result.mQ[0] == result1.mQ[0]) &&
			(result.mQ[1] == result1.mQ[1]) &&
			(result.mQ[2] == result1.mQ[2]) &&
			(result.mQ[3] == result1.mQ[3]));
	}
	
	template<> template<>
	void llquat_test_object_t::test<15>()
	{
		// test cases for inline LLQuaternion operator~(const LLQuaternion &a)
		LLQuaternion quat_val(2323.634f, -43535.4f, 3455.88f, -32232.45f);
		LLQuaternion result = ~quat_val;
		ensure(
			"1. LLQuaternion operator~(const LLQuaternion &a) failed ", 
			(-2323.634f == result.mQ[0]) &&
			(43535.4f == result.mQ[1]) &&
			(-3455.88f == result.mQ[2]) &&
			(-32232.45f == result.mQ[3]));

		//test case for inline bool LLQuaternion::operator==(const LLQuaternion &b) const
		LLQuaternion quat_val1(2323.634f, -43535.4f, 3455.88f, -32232.45f);
		LLQuaternion quat_val2(2323.634f, -43535.4f, 3455.88f, -32232.45f);
		ensure(
			"2. LLQuaternion::operator==(const LLQuaternion &b) failed",
			quat_val1 == quat_val2);
	}
	
	template<> template<>
	void llquat_test_object_t::test<16>()
	{
		//test case for inline bool LLQuaternion::operator!=(const LLQuaternion &b) const
		LLQuaternion quat_val1(2323.634f, -43535.4f, 3455.88f, -32232.45f);
		LLQuaternion quat_val2(0, -43535.4f, 3455.88f, -32232.45f);
		ensure("LLQuaternion::operator!=(const LLQuaternion &b) failed", quat_val1 != quat_val2);
	}

	template<> template<>
	void llquat_test_object_t::test<17>()
	{
		//test case for LLQuaternion mayaQ(F32 xRot, F32 yRot, F32 zRot, LLQuaternion::Order order)
		F32 x = 2.0f;
		F32 y = 1.0f;
		F32 z = 3.0f;
		
		LLQuaternion result = mayaQ(x, y, z, LLQuaternion::XYZ);
		ensure(
			"1. LLQuaternion mayaQ(F32 xRot, F32 yRot, F32 zRot, LLQuaternion::Order order) failed for XYZ",
			is_approx_equal_fraction(0.0172174f, result.mQ[0], 16) &&
			is_approx_equal_fraction(0.009179f, result.mQ[1], 16) &&
			is_approx_equal_fraction(0.026020f, result.mQ[2], 16) &&
			is_approx_equal_fraction(0.999471f, result.mQ[3], 16));

		LLQuaternion result1 = mayaQ(x, y, z, LLQuaternion::YZX);
		ensure(
			"2. LLQuaternion mayaQ(F32 xRot, F32 yRot, F32 zRot, LLQuaternion::Order order) failed for XYZ",
			is_approx_equal_fraction(0.017217f, result1.mQ[0], 16) &&
			is_approx_equal_fraction(0.008265f, result1.mQ[1], 16) &&
			is_approx_equal_fraction(0.026324f, result1.mQ[2], 16) &&
			is_approx_equal_fraction(0.999471f, result1.mQ[3], 16));
		
		LLQuaternion result2 = mayaQ(x, y, z, LLQuaternion::ZXY);
		ensure(
			"3. LLQuaternion mayaQ(F32 xRot, F32 yRot, F32 zRot, LLQuaternion::Order order) failed for ZXY", 
			is_approx_equal_fraction(0.017674f, result2.mQ[0], 16) &&
			is_approx_equal_fraction(0.008265f, result2.mQ[1], 16) &&
			is_approx_equal_fraction(0.026020f, result2.mQ[2], 16) &&
			is_approx_equal_fraction(0.999471f, result2.mQ[3], 16));
											
		LLQuaternion result3 = mayaQ(x, y, z, LLQuaternion::XZY);
		ensure(
			"4. TLLQuaternion mayaQ(F32 xRot, F32 yRot, F32 zRot, LLQuaternion::Order order) failed for XZY", 
			is_approx_equal_fraction(0.017674f, result3.mQ[0], 16) &&
			is_approx_equal_fraction(0.009179f, result3.mQ[1], 16) &&
			is_approx_equal_fraction(0.026020f, result3.mQ[2], 16) &&
			is_approx_equal_fraction(0.999463f, result3.mQ[3], 16));
											
		LLQuaternion result4 = mayaQ(x, y, z, LLQuaternion::YXZ);
		ensure(
			"5. LLQuaternion mayaQ(F32 xRot, F32 yRot, F32 zRot, LLQuaternion::Order order) failed for YXZ", 
			is_approx_equal_fraction(0.017217f, result4.mQ[0], 16) &&
			is_approx_equal_fraction(0.009179f, result4.mQ[1], 16) &&
			is_approx_equal_fraction(0.026324f, result4.mQ[2], 16) &&
			is_approx_equal_fraction(0.999463f, result4.mQ[3], 16));
											
		LLQuaternion result5 = mayaQ(x, y, z, LLQuaternion::ZYX);
		ensure(
			"6. LLQuaternion mayaQ(F32 xRot, F32 yRot, F32 zRot, LLQuaternion::Order order) failed for ZYX", 
			is_approx_equal_fraction(0.017674f, result5.mQ[0], 16) &&
			is_approx_equal_fraction(0.008265f, result5.mQ[1], 16) &&
			is_approx_equal_fraction(0.026324f, result5.mQ[2], 16) &&
			is_approx_equal_fraction(0.999463f, result5.mQ[3], 16));
	}

	template<> template<>
	void llquat_test_object_t::test<18>()
	{
		// test case for friend std::ostream& operator<<(std::ostream &s, const LLQuaternion &a) fn
		LLQuaternion a(1.0f, 1.0f, 1.0f, 1.0f); 
		std::ostringstream result_value;
		result_value << a;
		ensure_equals("1. Operator << failed", result_value.str(), "{ 1, 1, 1, 1 }");

		LLQuaternion b(-31.034f, 231.2340f, 3451.344320f, -341.0f); 
		std::ostringstream result_value1;
		result_value1 << b;
		ensure_equals("2. Operator << failed", result_value1.str(), "{ -31.034, 231.234, 3451.34, -341 }");

		LLQuaternion c(1.0f, 2.2f, 3.3f, 4.4f); 
		result_value << c;
		ensure_equals("3. Operator << failed", result_value.str(), "{ 1, 1, 1, 1 }{ 1, 2.2, 3.3, 4.4 }");

	}
	
	template<> template<>
	void llquat_test_object_t::test<19>()
	{
		//test case for const char *OrderToString( const LLQuaternion::Order order ) fn
		const char* result = OrderToString(LLQuaternion::XYZ);
		ensure("1. OrderToString failed for XYZ",  (0 == strcmp("XYZ", result)));
		
		result = OrderToString(LLQuaternion::YZX);
		ensure("2. OrderToString failed for YZX",  (0 == strcmp("YZX", result)));
		
		result = OrderToString(LLQuaternion::ZXY);
		ensure(
			"3. OrderToString failed for ZXY",
			(0 == strcmp("ZXY", result)) &&
			(0 != strcmp("XYZ", result)) &&
			(0 != strcmp("YXZ", result)) &&
			(0 != strcmp("ZYX", result)) &&
			(0 != strcmp("XYZ", result)));

		result = OrderToString(LLQuaternion::XZY);
		ensure("4. OrderToString failed for XZY",  (0 == strcmp("XZY", result)));

		result = OrderToString(LLQuaternion::ZYX);
		ensure("5. OrderToString failed for ZYX",  (0 == strcmp("ZYX", result)));

		result = OrderToString(LLQuaternion::YXZ);
		ensure("6.OrderToString failed for YXZ",  (0 == strcmp("YXZ", result)));
	}

	template<> template<>
	void llquat_test_object_t::test<20>()
	{
		//test case for LLQuaternion::Order StringToOrder( const char *str ) fn
		int result = StringToOrder("XYZ");
		ensure("1. LLQuaternion::Order StringToOrder(const char *str ) failed for XYZ", 0 == result);

		result = StringToOrder("YZX");
		ensure("2. LLQuaternion::Order StringToOrder(const char *str) failed for YZX", 1 == result);

		result = StringToOrder("ZXY");
		ensure("3. LLQuaternion::Order StringToOrder(const char *str) failed for ZXY", 2 == result);
		
		result = StringToOrder("XZY");
		ensure("4. LLQuaternion::Order StringToOrder(const char *str) failed for XZY", 3 == result);

		result = StringToOrder("YXZ");
		ensure("5. LLQuaternion::Order StringToOrder(const char *str) failed for YXZ", 4 == result);
	
		result = StringToOrder("ZYX");
		ensure("6. LLQuaternion::Order StringToOrder(const char *str) failed for  ZYX", 5 == result);	

	}

	template<> template<>
	void llquat_test_object_t::test<21>()
	{
		//void LLQuaternion::getAngleAxis(F32* angle, LLVector3 &vec) const fn
		F32 angle_value = 90.0f;
		LLVector3 vect(12.0f, 4.0f, 1.0f);
		LLQuaternion llquat(angle_value, vect);
		llquat.getAngleAxis(&angle_value, vect); 
		ensure(
			"LLQuaternion::getAngleAxis(F32* angle, LLVector3 &vec) failed", 
			is_approx_equal_fraction(2.035406f, angle_value, 16) &&
			is_approx_equal_fraction(0.315244f, vect.mV[1], 16) &&
			is_approx_equal_fraction(0.078811f, vect.mV[2], 16) &&
			is_approx_equal_fraction(0.945733f, vect.mV[0], 16));
	}

	template<> template<>
	void llquat_test_object_t::test<22>()
	{
		//test case for void LLQuaternion::getEulerAngles(F32 *roll, F32 *pitch, F32 *yaw) const fn
		F32 roll = -12.0f;
		F32 pitch = -22.43f;
		F32 yaw = 11.0f;

		LLQuaternion llquat;
		llquat.getEulerAngles(&roll, &pitch, &yaw);
		ensure(
			"LLQuaternion::getEulerAngles(F32 *roll, F32 *pitch, F32 *yaw) failed",
			is_approx_equal(0.000f, llquat.mQ[0]) &&
			is_approx_equal(0.000f, llquat.mQ[1]) &&
			is_approx_equal(0.000f, llquat.mQ[2]) &&
			is_approx_equal(1.000f, llquat.mQ[3]));
	}

}