rsspice 0.1.0

Pure Rust port of the SPICE Toolkit for space geometry
Documentation
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
//
// GENERATED FILE
//

use super::*;
use f2rust_std::*;

const DTOL: f64 = 0.00000000000001;
const MTOL: f64 = 0.00000000000001;
const NTOL: f64 = 0.00000000000001;
const ANGTOL: f64 = 0.000000000002;
const MSGLEN: i32 = 240;
const NUMCAS: i32 = 300;

struct SaveVars {
    NEXT: StackArray<i32, 4>,
}

impl SaveInit for SaveVars {
    fn new() -> Self {
        let mut NEXT = StackArray::<i32, 4>::new(1..=4);

        {
            use f2rust_std::data::Val;

            let mut clist = [Val::I(2), Val::I(3), Val::I(1), Val::I(2)].into_iter();
            NEXT.iter_mut()
                .for_each(|n| *n = clist.next().unwrap().into_i32());

            debug_assert!(clist.next().is_none(), "DATA not fully initialised");
        }

        Self { NEXT }
    }
}

//$Procedure F_EULER ( Test the SPICELIB Euler angle routines )
pub fn F_EULER(OK: &mut bool, ctx: &mut Context) -> f2rust_std::Result<()> {
    let save = ctx.get_vars::<SaveVars>();
    let save = &mut *save.borrow_mut();

    let mut TITLE = [b' '; MSGLEN as usize];
    let mut ANGLE = StackArray::<f64, 3>::new(1..=3);
    let mut LB: f64 = 0.0;
    let mut Q = StackArray::<f64, 4>::new(0..=3);
    let mut Q1 = StackArray::<f64, 4>::new(0..=3);
    let mut Q2 = StackArray::<f64, 4>::new(0..=3);
    let mut Q3 = StackArray::<f64, 4>::new(0..=3);
    let mut QTEMP = StackArray::<f64, 4>::new(0..=3);
    let mut R = StackArray2D::<f64, 9>::new(1..=3, 1..=3);
    let mut UB: f64 = 0.0;
    let mut XANGLE = StackArray::<f64, 3>::new(1..=3);
    let mut XR = StackArray2D::<f64, 9>::new(1..=3, 1..=3);
    let mut SEED: i32 = 0;
    let mut ABC: bool = false;
    let mut IS: bool = false;
    let mut RHAND: bool = false;

    //
    // SPICELIB functions
    //

    //
    // Other functions
    //

    //
    // Local Parameters
    //

    //
    // NUMCAS is the number of random Euler angle sequence test
    // cases per axis sequence.  Since there are 27 axis sequences
    // for the EUL2M tests and 12 sequences for the M2EUL tests,
    // and since we use a random selection of angles for each, we
    // actually have 8100 random cases for EUL2M and 3600 for M2EUL.
    //

    //
    // Local Variables
    //

    //
    // Saved values
    //

    //
    // Initial values
    //

    //
    // The principal test approach is as follows: we'll construct
    // rotation matrices from sets of Euler angles using EUL2M.  We'll
    // use an alternate, computationally independent approach to
    // construct the expected matrices and compare the output of EUL2M
    // against the expected results.
    //
    // Having in hand rotations with known Euler angle factorizations,
    // we'll use M2EUL to recover the original angles.
    //
    // The EUL2M tests will be performed using every possible Euler axis
    // sequence.
    //
    // The M2EUL tests will be restricted to Euler axis sequences of the
    // forms
    //
    //    a-b-a
    //    a-b-c
    //
    // since M2EUL doesn't allow axis sequences where the middle axis is
    // equal to one of the others.
    //

    //
    // Open the test family.
    //
    testutil::TOPEN(b"F_EULER", ctx)?;

    SEED = -1;

    //
    // We'll perform tests for each possible axis sequence.
    //
    for AXIS1 in 1..=3 {
        for AXIS2 in 1..=3 {
            for AXIS3 in 1..=3 {
                for CASE in 1..=NUMCAS {
                    //
                    // --- Case: ------------------------------------------------------
                    //
                    //
                    //                 Test EUL2M.  Select random Euler angles; construct
                    //                 a rotation matrix.
                    //
                    XANGLE[1] =
                        testutil::T_RANDD(-spicelib::PI(ctx), spicelib::PI(ctx), &mut SEED, ctx)?;

                    //
                    // The range of the middle angle depends on
                    // the type of axis sequence.  This is a matter
                    // of convention, not mathematics.
                    //
                    if (AXIS1 == AXIS3) {
                        LB = 0.0;
                        UB = spicelib::PI(ctx);
                    } else {
                        LB = -spicelib::HALFPI(ctx);
                        UB = spicelib::HALFPI(ctx);
                    }

                    XANGLE[2] = testutil::T_RANDD(LB, UB, &mut SEED, ctx)?;

                    XANGLE[3] =
                        testutil::T_RANDD(-spicelib::PI(ctx), spicelib::PI(ctx), &mut SEED, ctx)?;

                    fstr::assign(&mut TITLE, b"Test EUL2M: Create a rotation matrix from a random sequence of Euler angles; case = #.  Axis sequence = # # #. Angle sequence = # # #.");

                    spicelib::REPMI(&TITLE.clone(), b"#", CASE, &mut TITLE, ctx);
                    spicelib::REPMI(&TITLE.clone(), b"#", AXIS3, &mut TITLE, ctx);
                    spicelib::REPMI(&TITLE.clone(), b"#", AXIS2, &mut TITLE, ctx);
                    spicelib::REPMI(&TITLE.clone(), b"#", AXIS1, &mut TITLE, ctx);
                    spicelib::REPMD(&TITLE.clone(), b"#", XANGLE[3], 14, &mut TITLE, ctx);
                    spicelib::REPMD(&TITLE.clone(), b"#", XANGLE[2], 14, &mut TITLE, ctx);
                    spicelib::REPMD(&TITLE.clone(), b"#", XANGLE[1], 14, &mut TITLE, ctx);

                    testutil::TCASE(&TITLE, ctx)?;

                    //
                    // Build the rotation matrix R.
                    //
                    spicelib::EUL2M(
                        XANGLE[3],
                        XANGLE[2],
                        XANGLE[1],
                        AXIS3,
                        AXIS2,
                        AXIS1,
                        R.as_slice_mut(),
                        ctx,
                    )?;
                    testutil::CHCKXC(false, b" ", OK, ctx)?;

                    //
                    // Verify that EUL2M created a rotation matrix.
                    //
                    IS = spicelib::ISROT(R.as_slice(), DTOL, NTOL, ctx)?;

                    testutil::CHCKSL(b"Is R a rotation?", IS, true, OK, ctx)?;

                    //
                    // Validate the rotation by building the same
                    // matrix using quaternions.  Construct a
                    // quaternion corresponding to each factor rotation.
                    //
                    spicelib::CLEARD(4, Q1.as_slice_mut());

                    Q1[0] = f64::cos(-(XANGLE[1] / 2.0));
                    Q1[AXIS1] = f64::sin(-(XANGLE[1] / 2.0));

                    spicelib::CLEARD(4, Q2.as_slice_mut());

                    Q2[0] = f64::cos(-(XANGLE[2] / 2.0));
                    Q2[AXIS2] = f64::sin(-(XANGLE[2] / 2.0));

                    spicelib::CLEARD(4, Q3.as_slice_mut());

                    Q3[0] = f64::cos(-(XANGLE[3] / 2.0));
                    Q3[AXIS3] = f64::sin(-(XANGLE[3] / 2.0));

                    //
                    // Compute the product quaternion
                    //
                    //    Q = Q3*Q2*Q1
                    //
                    spicelib::QXQ(Q3.as_slice(), Q2.as_slice(), QTEMP.as_slice_mut());
                    spicelib::QXQ(QTEMP.as_slice(), Q1.as_slice(), Q.as_slice_mut());

                    //
                    // Convert Q to a rotation matrix for comparison.
                    //
                    spicelib::Q2M(Q.as_slice(), XR.as_slice_mut());

                    //
                    // How close is R to XR?
                    //
                    testutil::CHCKAD(b"R", R.as_slice(), b"~", XR.as_slice(), 3, MTOL, OK, ctx)?;

                    //
                    // --- Case: ------------------------------------------------------
                    //
                    //
                    //                 Test EUL2M.  Decompose the rotation matrix
                    //                 created using EUL2M.
                    //
                    //                 Skip the cases where AXIS2 == AXIS1 or AXIS3.
                    //
                    if ((AXIS2 != AXIS1) && (AXIS2 != AXIS3)) {
                        fstr::assign(&mut TITLE, b"Test M2EUL: Factor a rotation matrix from a random sequence of Euler angles; case = #.  Axis sequence = # # #. Angle sequence = # # #.");

                        spicelib::REPMI(&TITLE.clone(), b"#", CASE, &mut TITLE, ctx);
                        spicelib::REPMI(&TITLE.clone(), b"#", AXIS3, &mut TITLE, ctx);
                        spicelib::REPMI(&TITLE.clone(), b"#", AXIS2, &mut TITLE, ctx);
                        spicelib::REPMI(&TITLE.clone(), b"#", AXIS1, &mut TITLE, ctx);
                        spicelib::REPMD(&TITLE.clone(), b"#", XANGLE[3], 14, &mut TITLE, ctx);
                        spicelib::REPMD(&TITLE.clone(), b"#", XANGLE[2], 14, &mut TITLE, ctx);
                        spicelib::REPMD(&TITLE.clone(), b"#", XANGLE[1], 14, &mut TITLE, ctx);

                        testutil::TCASE(&TITLE, ctx)?;

                        //
                        // Decompose the matrix.
                        //
                        let [arg4, arg5, arg6] = ANGLE.get_disjoint_mut([3, 2, 1]).expect(
                            "mutable array elements passed to function must have disjoint indexes",
                        );
                        spicelib::M2EUL(R.as_slice(), AXIS3, AXIS2, AXIS1, arg4, arg5, arg6, ctx)?;

                        testutil::CHCKXC(false, b" ", OK, ctx)?;

                        //
                        // Test the recovered Euler angles.
                        //
                        testutil::CHCKAD(
                            b"Euler angles",
                            ANGLE.as_slice(),
                            b"~",
                            XANGLE.as_slice(),
                            3,
                            ANGTOL,
                            OK,
                            ctx,
                        )?;
                    }
                }
            }
        }
    }

    //
    // There is also a set of special cases for M2EUL:  those for
    // which ANGLE3 and ANGLE1 are not uniquely determined.  For
    // these cases, we expect that ANGLE3 is set to zero and ANGLE1
    // "absorbs" any contribution from ANGLE3.
    //
    // We don't need to test the numeric performance of M2EUL here
    // (we just did that), so we won't run a large number of cases.
    // We do need to make sure we try every valid axis sequence.
    //
    for AXIS1 in 1..=3 {
        for AXIS2 in 1..=3 {
            for AXIS3 in 1..=3 {
                if ((AXIS2 != AXIS1) && (AXIS2 != AXIS3)) {
                    for CASE in 1..=2 {
                        //
                        // --- Case: ------------------------------------------------------
                        //
                        //
                        //                    If we have an a-b-a rotation, we need to
                        //                    test the cases where the middle angle is zero
                        //                    or pi.  For the a-b-c rotations, we need to
                        //                    test the cases where the middle angle is
                        //                    +/- pi/2.
                        //
                        //                    We'll use the same first and third angles for
                        //                    each case.
                        //
                        XANGLE[3] = (spicelib::PI(ctx) / 6.0);
                        XANGLE[1] = (spicelib::PI(ctx) / 3.0);

                        if (AXIS3 == AXIS1) {
                            //
                            // This is the a-b-a case.
                            //
                            ABC = false;

                            if (CASE == 1) {
                                XANGLE[2] = 0.0;
                            } else {
                                XANGLE[2] = spicelib::PI(ctx);
                            }
                        } else {
                            //
                            // This is the a-b-c case.
                            //
                            ABC = true;

                            if (CASE == 1) {
                                XANGLE[2] = spicelib::HALFPI(ctx);
                            } else {
                                XANGLE[2] = -spicelib::HALFPI(ctx);
                            }
                        }

                        fstr::assign(&mut TITLE, b"Test M2EUL: Factor a rotation matrix from a sequence of Euler angles; special case = #.  Axis sequence = # # #. Angle sequence = # # #.");

                        spicelib::REPMI(&TITLE.clone(), b"#", CASE, &mut TITLE, ctx);
                        spicelib::REPMI(&TITLE.clone(), b"#", AXIS3, &mut TITLE, ctx);
                        spicelib::REPMI(&TITLE.clone(), b"#", AXIS2, &mut TITLE, ctx);
                        spicelib::REPMI(&TITLE.clone(), b"#", AXIS1, &mut TITLE, ctx);
                        spicelib::REPMD(&TITLE.clone(), b"#", XANGLE[3], 14, &mut TITLE, ctx);
                        spicelib::REPMD(&TITLE.clone(), b"#", XANGLE[2], 14, &mut TITLE, ctx);
                        spicelib::REPMD(&TITLE.clone(), b"#", XANGLE[1], 14, &mut TITLE, ctx);

                        testutil::TCASE(&TITLE, ctx)?;

                        //
                        // Create the rotation matrix.
                        //
                        spicelib::EUL2M(
                            XANGLE[3],
                            XANGLE[2],
                            XANGLE[1],
                            AXIS3,
                            AXIS2,
                            AXIS1,
                            XR.as_slice_mut(),
                            ctx,
                        )?;
                        testutil::CHCKXC(false, b" ", OK, ctx)?;

                        //
                        // Now decompose the matrix.
                        //
                        let [arg4, arg5, arg6] = ANGLE.get_disjoint_mut([3, 2, 1]).expect(
                            "mutable array elements passed to function must have disjoint indexes",
                        );
                        spicelib::M2EUL(XR.as_slice(), AXIS3, AXIS2, AXIS1, arg4, arg5, arg6, ctx)?;

                        testutil::CHCKXC(false, b" ", OK, ctx)?;

                        //
                        // Due to round-off error, we might not have
                        // succeeded in constructing a matrix that
                        // decomposes as we expect.  If the third angle
                        // is zero, perform the test for the special case.
                        // Otherwise, just confirm that the Euler angles
                        // we found generate the original matrix.
                        //
                        if (ANGLE[3] == 0.0) {
                            //
                            // Test the recovered Euler angles.  We first
                            // adjust the expected first and third angles.
                            //
                            if ABC {
                                //
                                // The way the first and third angles
                                // combine is a bit complicated:  it
                                // depends on whether the axis sequence
                                // is right-handed.
                                //
                                RHAND =
                                    ((AXIS2 == save.NEXT[AXIS1]) && (AXIS3 == save.NEXT[AXIS2]));

                                if RHAND {
                                    if (CASE == 1) {
                                        //
                                        // The first and third angles combine
                                        // additively.
                                        //
                                        XANGLE[1] = (XANGLE[1] + XANGLE[3]);
                                    } else {
                                        //
                                        // The third angle acts as a negative
                                        // rotation about the first axis.
                                        //
                                        XANGLE[1] = (XANGLE[1] - XANGLE[3]);
                                    }
                                } else {
                                    //
                                    // For left-handed axis sequences, the
                                    // combination pattern is reversed.
                                    //
                                    if (CASE == 2) {
                                        //
                                        // The first and third angles combine
                                        // additively.
                                        //
                                        XANGLE[1] = (XANGLE[1] + XANGLE[3]);
                                    } else {
                                        //
                                        // The third angle acts as a negative
                                        // rotation about the first axis.
                                        //
                                        XANGLE[1] = (XANGLE[1] - XANGLE[3]);
                                    }
                                }
                            } else {
                                if (CASE == 1) {
                                    //
                                    // The first and third angles combine
                                    // additively.
                                    //
                                    XANGLE[1] = (XANGLE[1] + XANGLE[3]);
                                } else {
                                    //
                                    // The third angle acts as a negative
                                    // rotation about the first axis.
                                    //
                                    XANGLE[1] = (XANGLE[1] - XANGLE[3]);
                                }
                            }

                            XANGLE[3] = 0.0;

                            testutil::CHCKAD(
                                b"Euler angles",
                                ANGLE.as_slice(),
                                b"~",
                                XANGLE.as_slice(),
                                3,
                                ANGTOL,
                                OK,
                                ctx,
                            )?;
                        }

                        //
                        // Always test the angles produced by M2EUL to see
                        // whether we can recover XR from them.  This is
                        // the most basic test of validity of the angles:
                        // even when the geometry is degenerate, we should be
                        // able to find angles that correspond to the same
                        // composite rotation produced by the original angles.
                        //
                        spicelib::EUL2M(
                            ANGLE[3],
                            ANGLE[2],
                            ANGLE[1],
                            AXIS3,
                            AXIS2,
                            AXIS1,
                            R.as_slice_mut(),
                            ctx,
                        )?;

                        testutil::CHCKAD(
                            b"Recovered matrix",
                            R.as_slice(),
                            b"~",
                            XR.as_slice(),
                            9,
                            MTOL,
                            OK,
                            ctx,
                        )?;
                    }
                }
            }
        }
    }

    //
    //     Now for some error handling tests.
    //
    //
    //
    //     Error cases for EUL2M:
    //
    //
    // --- Case: ------------------------------------------------------
    //
    testutil::TCASE(b"EUL2M: axis numbers out of range.", ctx)?;

    spicelib::EUL2M(ANGLE[3], ANGLE[2], ANGLE[1], 0, 1, 3, R.as_slice_mut(), ctx)?;
    testutil::CHCKXC(true, b"SPICE(BADAXISNUMBERS)", OK, ctx)?;

    spicelib::EUL2M(ANGLE[3], ANGLE[2], ANGLE[1], 4, 1, 3, R.as_slice_mut(), ctx)?;
    testutil::CHCKXC(true, b"SPICE(BADAXISNUMBERS)", OK, ctx)?;

    spicelib::EUL2M(ANGLE[3], ANGLE[2], ANGLE[1], 3, 0, 3, R.as_slice_mut(), ctx)?;
    testutil::CHCKXC(true, b"SPICE(BADAXISNUMBERS)", OK, ctx)?;

    spicelib::EUL2M(ANGLE[3], ANGLE[2], ANGLE[1], 3, 4, 3, R.as_slice_mut(), ctx)?;
    testutil::CHCKXC(true, b"SPICE(BADAXISNUMBERS)", OK, ctx)?;

    spicelib::EUL2M(ANGLE[3], ANGLE[2], ANGLE[1], 3, 1, 0, R.as_slice_mut(), ctx)?;
    testutil::CHCKXC(true, b"SPICE(BADAXISNUMBERS)", OK, ctx)?;

    spicelib::EUL2M(ANGLE[3], ANGLE[2], ANGLE[1], 3, 1, 4, R.as_slice_mut(), ctx)?;
    testutil::CHCKXC(true, b"SPICE(BADAXISNUMBERS)", OK, ctx)?;

    //
    //     Error cases for M2EUL:
    //
    //
    // --- Case: ------------------------------------------------------
    //
    testutil::TCASE(b"M2EUL: axis numbers out of range.", ctx)?;

    let [arg4, arg5, arg6] = ANGLE
        .get_disjoint_mut([3, 2, 1])
        .expect("mutable array elements passed to function must have disjoint indexes");
    spicelib::M2EUL(R.as_slice(), 0, 1, 3, arg4, arg5, arg6, ctx)?;
    testutil::CHCKXC(true, b"SPICE(BADAXISNUMBERS)", OK, ctx)?;

    let [arg4, arg5, arg6] = ANGLE
        .get_disjoint_mut([3, 2, 1])
        .expect("mutable array elements passed to function must have disjoint indexes");
    spicelib::M2EUL(R.as_slice(), 4, 1, 3, arg4, arg5, arg6, ctx)?;
    testutil::CHCKXC(true, b"SPICE(BADAXISNUMBERS)", OK, ctx)?;

    let [arg4, arg5, arg6] = ANGLE
        .get_disjoint_mut([3, 2, 1])
        .expect("mutable array elements passed to function must have disjoint indexes");
    spicelib::M2EUL(R.as_slice(), 3, 0, 3, arg4, arg5, arg6, ctx)?;
    testutil::CHCKXC(true, b"SPICE(BADAXISNUMBERS)", OK, ctx)?;

    let [arg4, arg5, arg6] = ANGLE
        .get_disjoint_mut([3, 2, 1])
        .expect("mutable array elements passed to function must have disjoint indexes");
    spicelib::M2EUL(R.as_slice(), 3, 4, 3, arg4, arg5, arg6, ctx)?;
    testutil::CHCKXC(true, b"SPICE(BADAXISNUMBERS)", OK, ctx)?;

    let [arg4, arg5, arg6] = ANGLE
        .get_disjoint_mut([3, 2, 1])
        .expect("mutable array elements passed to function must have disjoint indexes");
    spicelib::M2EUL(R.as_slice(), 3, 1, 0, arg4, arg5, arg6, ctx)?;
    testutil::CHCKXC(true, b"SPICE(BADAXISNUMBERS)", OK, ctx)?;

    let [arg4, arg5, arg6] = ANGLE
        .get_disjoint_mut([3, 2, 1])
        .expect("mutable array elements passed to function must have disjoint indexes");
    spicelib::M2EUL(R.as_slice(), 3, 1, 4, arg4, arg5, arg6, ctx)?;
    testutil::CHCKXC(true, b"SPICE(BADAXISNUMBERS)", OK, ctx)?;

    //
    // --- Case: ------------------------------------------------------
    //
    testutil::TCASE(b"M2EUL: middle axis matches first or third axis.", ctx)?;

    let [arg4, arg5, arg6] = ANGLE
        .get_disjoint_mut([3, 2, 1])
        .expect("mutable array elements passed to function must have disjoint indexes");
    spicelib::M2EUL(R.as_slice(), 3, 3, 1, arg4, arg5, arg6, ctx)?;
    testutil::CHCKXC(true, b"SPICE(BADAXISNUMBERS)", OK, ctx)?;

    let [arg4, arg5, arg6] = ANGLE
        .get_disjoint_mut([3, 2, 1])
        .expect("mutable array elements passed to function must have disjoint indexes");
    spicelib::M2EUL(R.as_slice(), 1, 3, 3, arg4, arg5, arg6, ctx)?;
    testutil::CHCKXC(true, b"SPICE(BADAXISNUMBERS)", OK, ctx)?;

    let [arg4, arg5, arg6] = ANGLE
        .get_disjoint_mut([3, 2, 1])
        .expect("mutable array elements passed to function must have disjoint indexes");
    spicelib::M2EUL(R.as_slice(), 2, 2, 1, arg4, arg5, arg6, ctx)?;
    testutil::CHCKXC(true, b"SPICE(BADAXISNUMBERS)", OK, ctx)?;

    let [arg4, arg5, arg6] = ANGLE
        .get_disjoint_mut([3, 2, 1])
        .expect("mutable array elements passed to function must have disjoint indexes");
    spicelib::M2EUL(R.as_slice(), 1, 2, 2, arg4, arg5, arg6, ctx)?;
    testutil::CHCKXC(true, b"SPICE(BADAXISNUMBERS)", OK, ctx)?;

    let [arg4, arg5, arg6] = ANGLE
        .get_disjoint_mut([3, 2, 1])
        .expect("mutable array elements passed to function must have disjoint indexes");
    spicelib::M2EUL(R.as_slice(), 1, 1, 3, arg4, arg5, arg6, ctx)?;
    testutil::CHCKXC(true, b"SPICE(BADAXISNUMBERS)", OK, ctx)?;

    let [arg4, arg5, arg6] = ANGLE
        .get_disjoint_mut([3, 2, 1])
        .expect("mutable array elements passed to function must have disjoint indexes");
    spicelib::M2EUL(R.as_slice(), 3, 1, 1, arg4, arg5, arg6, ctx)?;
    testutil::CHCKXC(true, b"SPICE(BADAXISNUMBERS)", OK, ctx)?;

    //
    // --- Case: ------------------------------------------------------
    //
    testutil::TCASE(b"M2EUL:  input matrix is not a rotation.", ctx)?;

    spicelib::FILLD(1.0, 9, R.as_slice_mut());

    let [arg4, arg5, arg6] = ANGLE
        .get_disjoint_mut([3, 2, 1])
        .expect("mutable array elements passed to function must have disjoint indexes");
    spicelib::M2EUL(R.as_slice(), 3, 1, 3, arg4, arg5, arg6, ctx)?;
    testutil::CHCKXC(true, b"SPICE(NOTAROTATION)", OK, ctx)?;

    //
    // Close out the test family.
    //
    testutil::T_SUCCESS(OK, ctx);
    Ok(())
}