engeom 0.5.0

Library for working with geometry with a focus on engineering metrology applications.
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
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
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
//! This module has additional tools and functions for working with 3D isometries

use crate::{Iso3, Line3, Point3, Result, UnitVec3, Vector3};
use consts::PI;
use parry3d_f64::na::{Matrix3, Translation3};
use parry3d_f64::na::{Matrix4, UnitQuaternion, try_convert};
use std::f64::consts;

pub trait IsoExtensions3 {
    /// Create an isometry that translates by the given x, y, and z distances, with no rotation.
    ///
    /// This is a pass-through to nalgebra's `Iso3::translation`, provided so that the
    /// constructor family on `Iso3` follows this project's `from_<description>` naming
    /// convention. It also avoids the ambiguity of the underlying name, which nalgebra uses for
    /// both this constructor and the isometry's public `translation` field.
    ///
    /// # Arguments
    ///
    /// * `x`: the distance to translate along the x-axis
    /// * `y`: the distance to translate along the y-axis
    /// * `z`: the distance to translate along the z-axis
    ///
    /// returns: Isometry<f64, Unit<Quaternion<f64>>, 3>
    ///
    /// # Examples
    ///
    /// ```
    /// use approx::assert_relative_eq;
    /// use engeom::{Iso3, Point3};
    /// use engeom::geom3::IsoExtensions3;
    ///
    /// let iso = Iso3::from_translation(1.0, 2.0, 3.0);
    /// assert_relative_eq!(iso * Point3::origin(), Point3::new(1.0, 2.0, 3.0), epsilon = 1e-10);
    /// ```
    fn from_translation(x: f64, y: f64, z: f64) -> Iso3;

    /// Create an isometry that rotates around the global origin by an axis-angle vector, with no
    /// translation.
    ///
    /// The vector encodes both the axis and the angle: its direction is the axis of rotation and
    /// its magnitude is the angle of rotation in radians. A zero-length vector produces the
    /// identity rotation. When the axis is pointed at the viewer, positive angles will produce
    /// rotations viewed as counter-clockwise.
    ///
    /// For the common cases there are more direct alternatives: `from_rx`, `from_ry`, and
    /// `from_rz` to rotate around a principal axis, and `from_rot_axis` to rotate around an
    /// arbitrary axis that doesn't pass through the origin.
    ///
    /// This is a pass-through to nalgebra's `Iso3::rotation`, provided so that the constructor
    /// family on `Iso3` follows this project's `from_<description>` naming convention.
    ///
    /// # Arguments
    ///
    /// * `axisangle`: a vector whose direction is the axis of rotation and whose magnitude is
    ///   the angle of rotation in radians. It is *not* normalized, because its length carries
    ///   the angle.
    ///
    /// returns: Isometry<f64, Unit<Quaternion<f64>>, 3>
    ///
    /// # Examples
    ///
    /// ```
    /// use std::f64::consts::FRAC_PI_2;
    /// use approx::assert_relative_eq;
    /// use engeom::{Iso3, Vector3};
    /// use engeom::geom3::IsoExtensions3;
    ///
    /// // Rotate a quarter turn around the z-axis
    /// let iso = Iso3::from_rotation(&(Vector3::z() * FRAC_PI_2));
    /// assert_relative_eq!(iso * Vector3::x(), Vector3::y(), epsilon = 1e-10);
    /// ```
    fn from_rotation(axisangle: &Vector3) -> Iso3;

    /// Tries to create an isometry from a 16-element array, which should contain the values of
    /// the transformation matrix in row-major order (the first four values are the first row,
    /// the next four are the second row, etc.).
    ///
    /// This will return an `Err` if the matrix values don't form a legitimate isometry.
    ///
    /// # Arguments
    ///
    /// * `array`: a 16-element floating point array containing the matrix values
    ///
    /// returns: Result<Isometry<f64, Unit<Quaternion<f64>>, 3>, Box<dyn Error, Global>>
    ///
    /// # Examples
    ///
    /// ```
    /// use approx::assert_relative_eq;
    /// use engeom::{Iso3, Point3};
    /// use engeom::geom3::IsoExtensions3;
    ///
    /// let array = [
    ///     1.0, 0.0, 0.0, 1.0,
    ///     0.0, 1.0, 0.0, 2.0,
    ///     0.0, 0.0, 1.0, 3.0,
    ///     0.0, 0.0, 0.0, 1.0,
    /// ];
    /// let iso = Iso3::from_array(&array).unwrap();
    /// let moved = iso * Point3::origin();
    /// assert_relative_eq!(moved, Point3::new(1.0, 2.0, 3.0), epsilon = 1e-10);
    /// ```
    fn from_array(array: &[f64; 16]) -> Result<Iso3>;

    /// Create an isometry from an arbitrary orthonormal basis spanning the plane perpendicular to
    /// `z`. There is no guarantee about the orientation of the `x` and `y` axes around the given
    /// `z` beyond their mutual perpendicularity.
    ///
    /// If no origin is specified, the global origin will be used.
    ///
    /// Use this only when the orientation of `x` and `y` really don't matter.
    ///
    /// # Arguments
    ///
    /// * `z`: a unit vector pointing in the direction of the result's Z axis
    /// * `origin`: an optional origin, if not provided the global origin will be used
    ///
    /// returns: Isometry<f64, Unit<Quaternion<f64>>, 3>
    fn from_z_arbitrary_xy(z: &UnitVec3, origin: Option<Point3>) -> Iso3;

    /// Try to create an isometry that rotates around an axis represented by a `Line3` entity by
    /// a given angle. This will only return an `Err` if the length of the line is zero.
    ///
    /// # Arguments
    ///
    /// * `axis`: the axis of rotation for the isometry. When the line direction is pointed at the
    ///   viewer, positive angles will produce rotations viewed as counter-clockwise
    /// * `angle`: the angle of rotation, specified in radians
    ///
    /// returns: Result<Isometry<f64, Unit<Quaternion<f64>>, 3>, Box<dyn Error, Global>>
    ///
    /// # Examples
    ///
    /// ```
    /// use std::f64::consts::PI;
    /// use approx::assert_relative_eq;
    /// use engeom::{Iso3, Line3, Point3, Vector3};
    /// use engeom::geom3::IsoExtensions3;
    ///
    /// let axis = Line3::new(Point3::new(1.0, 1.0, 0.0), Vector3::z());
    /// let iso = Iso3::from_rot_axis(&axis, PI / 2.0).unwrap();
    ///
    /// let result = iso * Point3::new(2.0, 1.0, 0.0);
    /// assert_relative_eq!(result, Point3::new(1.0, 2.0, 0.0), epsilon = 1e-6);
    /// ```
    fn from_rot_axis(axis: &Line3, angle: f64) -> Result<Iso3>;

    /// Try to create an isometry from two basis vectors and an optional origin. The primary basis
    /// vector will become the x-axis in the isometry, the secondary basis vector will be projected
    /// onto the primary and the remaining component will be the y-axis. The final axis will be
    /// computed by cross product for a right-handed coordinate system.
    ///
    /// The isometry produced by this method will move a point in the basis coordinate system to
    /// where it would be located in the world coordinate system.
    ///
    /// If you want to take features in the world coordinate system and move them into the basis
    /// coordinate system, you need to use the inverse of the isometry.
    ///
    /// # Arguments
    ///
    /// * `e0`: A vector in the world coordinate system that will become the x-axis in the basis
    ///   coordinate system, will be normalized to unit length automatically.
    /// * `e1`: A vector in the world coordinate system whose component linearly independent of `e0`
    ///   will become the y-axis in the basis coordinate system, will be normalized to unit length.
    /// * `origin`: An optional point in the world coordinate system that will be the origin of the
    ///   basis coordinate system. If not provided, the origin of the basis coordinate system will
    ///   be coincident with the origin of the world coordinate system.
    ///
    /// returns: Result<Isometry<f64, Unit<Quaternion<f64>>, 3>, Box<dyn Error, Global>>
    ///
    /// # Examples
    ///
    /// ```
    /// use approx::assert_relative_eq;
    /// use engeom::{Iso3, Point3, Vector3};
    /// use engeom::geom3::IsoExtensions3;
    ///
    /// // `e0` is tilted 45 degrees between the global x and y axes, while `e1` is already
    /// // orthogonal to it, so the two are easy to tell apart in the result.
    /// let e0 = Vector3::new(1.0, 1.0, 0.0);
    /// let e1 = Vector3::new(0.0, 0.0, 1.0);
    /// let origin = Point3::new(1.0, 2.0, 3.0);
    /// let iso = Iso3::from_basis_xy(&e0, &e1, Some(origin)).unwrap();
    ///
    /// assert_relative_eq!(iso * Point3::origin(), origin, epsilon = 1e-10);
    /// // The basis coordinate system's x-axis (1, 0, 0) lands on the normalized `e0`
    /// assert_relative_eq!(iso * Point3::new(1.0, 0.0, 0.0), origin + e0.normalize(), epsilon = 1e-10);
    /// // The basis coordinate system's y-axis (0, 1, 0) lands on `e1`, unchanged since it was
    /// // already orthogonal to `e0`
    /// assert_relative_eq!(iso * Point3::new(0.0, 1.0, 0.0), origin + e1, epsilon = 1e-10);
    /// ```
    fn from_basis_xy(e0: &Vector3, e1: &Vector3, origin: Option<Point3>) -> Result<Iso3>;

    /// Try to create an isometry from two basis vectors and an optional origin. The primary basis
    /// vector will become the x-axis in the isometry, the secondary basis vector will be projected
    /// onto the primary and the remaining component will be the z-axis. The final axis will be
    /// computed by cross product for a right-handed coordinate system.
    ///
    /// The isometry produced by this method will move a point in the basis coordinate system to
    /// where it would be located in the world coordinate system.
    ///
    /// If you want to take features in the world coordinate system and move them into the basis
    /// coordinate system, you need to use the inverse of the isometry.
    ///
    /// # Arguments
    ///
    /// * `e0`: A vector in the world coordinate system that will become the x-axis in the basis
    ///   coordinate system, will be normalized to unit length automatically.
    /// * `e2`: A vector in the world coordinate system whose component linearly independent of `e0`
    ///   will become the z-axis in the basis coordinate system, will be normalized to unit length.
    /// * `origin`: An optional point in the world coordinate system that will be the origin of the
    ///   basis coordinate system. If not provided, the origin of the basis coordinate system will
    ///   be coincident with the origin of the world coordinate system.
    ///
    /// returns: Result<Isometry<f64, Unit<Quaternion<f64>>, 3>, Box<dyn Error, Global>>
    ///
    /// # Examples
    ///
    /// ```
    /// use approx::assert_relative_eq;
    /// use engeom::{Iso3, Point3, Vector3};
    /// use engeom::geom3::IsoExtensions3;
    ///
    /// // `e0` is tilted 45 degrees between the global x and y axes, while `e2` is already
    /// // orthogonal to it, so the two are easy to tell apart in the result.
    /// let e0 = Vector3::new(1.0, 1.0, 0.0);
    /// let e2 = Vector3::new(0.0, 0.0, 1.0);
    /// let origin = Point3::new(1.0, 2.0, 3.0);
    /// let iso = Iso3::from_basis_xz(&e0, &e2, Some(origin)).unwrap();
    ///
    /// assert_relative_eq!(iso * Point3::origin(), origin, epsilon = 1e-10);
    /// // The basis coordinate system's x-axis (1, 0, 0) lands on the normalized `e0`
    /// assert_relative_eq!(iso * Point3::new(1.0, 0.0, 0.0), origin + e0.normalize(), epsilon = 1e-10);
    /// // The basis coordinate system's z-axis (0, 0, 1) lands on `e2`, unchanged since it was
    /// // already orthogonal to `e0`
    /// assert_relative_eq!(iso * Point3::new(0.0, 0.0, 1.0), origin + e2, epsilon = 1e-10);
    /// ```
    fn from_basis_xz(e0: &Vector3, e2: &Vector3, origin: Option<Point3>) -> Result<Iso3>;

    /// Try to create an isometry from two basis vectors and an optional origin. The primary basis
    /// vector will become the y-axis in the isometry, the secondary basis vector will be projected
    /// onto the primary and the remaining component will be the z-axis. The final axis will be
    /// computed by cross product for a right-handed coordinate system.
    ///
    /// The isometry produced by this method will move a point in the basis coordinate system to
    /// where it would be located in the world coordinate system.
    ///
    /// If you want to take features in the world coordinate system and move them into the basis
    /// coordinate system, you need to use the inverse of the isometry.
    ///
    /// # Arguments
    ///
    /// * `e1`: A vector in the world coordinate system that will become the y-axis in the basis
    ///   coordinate system, will be normalized to unit length automatically.
    /// * `e2`: A vector in the world coordinate system whose component linearly independent of `e1`
    ///   will become the z-axis in the basis coordinate system, will be normalized to unit length.
    /// * `origin`: An optional point in the world coordinate system that will be the origin of the
    ///   basis coordinate system. If not provided, the origin of the basis coordinate system will
    ///   be coincident with the origin of the world coordinate system.
    ///
    /// returns: Result<Isometry<f64, Unit<Quaternion<f64>>, 3>, Box<dyn Error, Global>>
    ///
    /// # Examples
    ///
    /// ```
    /// use approx::assert_relative_eq;
    /// use engeom::{Iso3, Point3, Vector3};
    /// use engeom::geom3::IsoExtensions3;
    ///
    /// // `e1` is tilted 45 degrees between the global x and y axes, while `e2` is already
    /// // orthogonal to it, so the two are easy to tell apart in the result.
    /// let e1 = Vector3::new(1.0, 1.0, 0.0);
    /// let e2 = Vector3::new(0.0, 0.0, 1.0);
    /// let origin = Point3::new(1.0, 2.0, 3.0);
    /// let iso = Iso3::from_basis_yz(&e1, &e2, Some(origin)).unwrap();
    ///
    /// assert_relative_eq!(iso * Point3::origin(), origin, epsilon = 1e-10);
    /// // The basis coordinate system's y-axis (0, 1, 0) lands on the normalized `e1`
    /// assert_relative_eq!(iso * Point3::new(0.0, 1.0, 0.0), origin + e1.normalize(), epsilon = 1e-10);
    /// // The basis coordinate system's z-axis (0, 0, 1) lands on `e2`, unchanged since it was
    /// // already orthogonal to `e1`
    /// assert_relative_eq!(iso * Point3::new(0.0, 0.0, 1.0), origin + e2, epsilon = 1e-10);
    /// ```
    fn from_basis_yz(e1: &Vector3, e2: &Vector3, origin: Option<Point3>) -> Result<Iso3>;

    /// Try to create an isometry from two basis vectors and an optional origin. The primary basis
    /// vector will become the y-axis in the isometry, the secondary basis vector will be projected
    /// onto the primary and the remaining component will be the x-axis. The final axis will be
    /// computed by cross product for a right-handed coordinate system.
    ///
    /// The isometry produced by this method will move a point in the basis coordinate system to
    /// where it would be located in the world coordinate system.
    ///
    /// If you want to take features in the world coordinate system and move them into the basis
    /// coordinate system, you need to use the inverse of the isometry.
    ///
    /// # Arguments
    ///
    /// * `e1`: A vector in the world coordinate system that will become the y-axis in the basis
    ///   coordinate system, will be normalized to unit length automatically.
    /// * `e0`: A vector in the world coordinate system whose component linearly independent of `e1`
    ///   will become the x-axis in the basis coordinate system, will be normalized to unit length.
    /// * `origin`: An optional point in the world coordinate system that will be the origin of the
    ///   basis coordinate system. If not provided, the origin of the basis coordinate system will
    ///   be coincident with the origin of the world coordinate system.
    ///
    /// returns: Result<Isometry<f64, Unit<Quaternion<f64>>, 3>, Box<dyn Error, Global>>
    ///
    /// # Examples
    ///
    /// ```
    /// use approx::assert_relative_eq;
    /// use engeom::{Iso3, Point3, Vector3};
    /// use engeom::geom3::IsoExtensions3;
    ///
    /// // `e1` is tilted 45 degrees between the global x and y axes, while `e0` is already
    /// // orthogonal to it, so the two are easy to tell apart in the result.
    /// let e1 = Vector3::new(1.0, 1.0, 0.0);
    /// let e0 = Vector3::new(0.0, 0.0, 1.0);
    /// let origin = Point3::new(1.0, 2.0, 3.0);
    /// let iso = Iso3::from_basis_yx(&e1, &e0, Some(origin)).unwrap();
    ///
    /// assert_relative_eq!(iso * Point3::origin(), origin, epsilon = 1e-10);
    /// // The basis coordinate system's y-axis (0, 1, 0) lands on the normalized `e1`
    /// assert_relative_eq!(iso * Point3::new(0.0, 1.0, 0.0), origin + e1.normalize(), epsilon = 1e-10);
    /// // The basis coordinate system's x-axis (1, 0, 0) lands on `e0`, unchanged since it was
    /// // already orthogonal to `e1`
    /// assert_relative_eq!(iso * Point3::new(1.0, 0.0, 0.0), origin + e0, epsilon = 1e-10);
    /// ```
    fn from_basis_yx(e1: &Vector3, e0: &Vector3, origin: Option<Point3>) -> Result<Iso3>;

    /// Try to create an isometry from two basis vectors and an optional origin. The primary basis
    /// vector will become the z-axis in the isometry, the secondary basis vector will be projected
    /// onto the primary and the remaining component will be the x-axis. The final axis will be
    /// computed by cross product for a right-handed coordinate system.
    ///
    /// The isometry produced by this method will move a point in the basis coordinate system to
    /// where it would be located in the world coordinate system.
    ///
    /// If you want to take features in the world coordinate system and move them into the basis
    /// coordinate system, you need to use the inverse of the isometry.
    ///
    /// # Arguments
    ///
    /// * `e2`: A vector in the world coordinate system that will become the z-axis in the basis
    ///   coordinate system, will be normalized to unit length automatically.
    /// * `e0`: A vector in the world coordinate system whose component linearly independent of `e2`
    ///   will become the x-axis in the basis coordinate system, will be normalized to unit length.
    /// * `origin`: An optional point in the world coordinate system that will be the origin of the
    ///   basis coordinate system. If not provided, the origin of the basis coordinate system will
    ///   be coincident with the origin of the world coordinate system.
    ///
    /// returns: Result<Isometry<f64, Unit<Quaternion<f64>>, 3>, Box<dyn Error, Global>>
    ///
    /// # Examples
    ///
    /// ```
    /// use approx::assert_relative_eq;
    /// use engeom::{Iso3, Point3, Vector3};
    /// use engeom::geom3::IsoExtensions3;
    ///
    /// // `e2` is tilted 45 degrees between the global x and y axes, while `e0` is already
    /// // orthogonal to it, so the two are easy to tell apart in the result.
    /// let e2 = Vector3::new(1.0, 1.0, 0.0);
    /// let e0 = Vector3::new(0.0, 0.0, 1.0);
    /// let origin = Point3::new(1.0, 2.0, 3.0);
    /// let iso = Iso3::from_basis_zx(&e2, &e0, Some(origin)).unwrap();
    ///
    /// assert_relative_eq!(iso * Point3::origin(), origin, epsilon = 1e-10);
    /// // The basis coordinate system's z-axis (0, 0, 1) lands on the normalized `e2`
    /// assert_relative_eq!(iso * Point3::new(0.0, 0.0, 1.0), origin + e2.normalize(), epsilon = 1e-10);
    /// // The basis coordinate system's x-axis (1, 0, 0) lands on `e0`, unchanged since it was
    /// // already orthogonal to `e2`
    /// assert_relative_eq!(iso * Point3::new(1.0, 0.0, 0.0), origin + e0, epsilon = 1e-10);
    /// ```
    fn from_basis_zx(e2: &Vector3, e0: &Vector3, origin: Option<Point3>) -> Result<Iso3>;

    /// Try to create an isometry from two basis vectors and an optional origin. The primary basis
    /// vector will become the z-axis in the isometry, the secondary basis vector will be projected
    /// onto the primary and the remaining component will be the y-axis. The final axis will be
    /// computed by cross product for a right-handed coordinate system.
    ///
    /// The isometry produced by this method will move a point in the basis coordinate system to
    /// where it would be located in the world coordinate system.
    ///
    /// If you want to take features in the world coordinate system and move them into the basis
    /// coordinate system, you need to use the inverse of the isometry.
    ///
    /// # Arguments
    ///
    /// * `e2`: A vector in the world coordinate system that will become the z-axis in the basis
    ///   coordinate system, will be normalized to unit length automatically.
    /// * `e1`: A vector in the world coordinate system whose component linearly independent of `e2`
    ///   will become the y-axis in the basis coordinate system, will be normalized to unit length.
    /// * `origin`: An optional point in the world coordinate system that will be the origin of the
    ///   basis coordinate system. If not provided, the origin of the basis coordinate system will
    ///   be coincident with the origin of the world coordinate system.
    ///
    /// returns: Result<Isometry<f64, Unit<Quaternion<f64>>, 3>, Box<dyn Error, Global>>
    ///
    /// # Examples
    ///
    /// ```
    /// use approx::assert_relative_eq;
    /// use engeom::{Iso3, Point3, Vector3};
    /// use engeom::geom3::IsoExtensions3;
    ///
    /// // `e2` is tilted 45 degrees between the global x and y axes, while `e1` is already
    /// // orthogonal to it, so the two are easy to tell apart in the result.
    /// let e2 = Vector3::new(1.0, 1.0, 0.0);
    /// let e1 = Vector3::new(0.0, 0.0, 1.0);
    /// let origin = Point3::new(1.0, 2.0, 3.0);
    /// let iso = Iso3::from_basis_zy(&e2, &e1, Some(origin)).unwrap();
    ///
    /// assert_relative_eq!(iso * Point3::origin(), origin, epsilon = 1e-10);
    /// // The basis coordinate system's z-axis (0, 0, 1) lands on the normalized `e2`
    /// assert_relative_eq!(iso * Point3::new(0.0, 0.0, 1.0), origin + e2.normalize(), epsilon = 1e-10);
    /// // The basis coordinate system's y-axis (0, 1, 0) lands on `e1`, unchanged since it was
    /// // already orthogonal to `e2`
    /// assert_relative_eq!(iso * Point3::new(0.0, 1.0, 0.0), origin + e1, epsilon = 1e-10);
    /// ```
    fn from_basis_zy(e2: &Vector3, e1: &Vector3, origin: Option<Point3>) -> Result<Iso3>;

    /// Create an isometry that rotates around the x-axis by a given angle. When the x-axis is
    /// pointed at the viewer, positive angles will produce rotations viewed as counter-clockwise.
    ///
    /// # Arguments
    ///
    /// * `angle`: angle of rotation, specified in radians
    ///
    /// returns: Isometry<f64, Unit<Quaternion<f64>>, 3>
    ///
    /// # Examples
    ///
    /// ```
    /// use std::f64::consts::PI;
    /// use approx::assert_relative_eq;
    /// use engeom::{Iso3, Vector3};
    /// use engeom::geom3::IsoExtensions3;
    ///
    /// let iso = Iso3::from_rx(PI / 2.0);
    /// let rotated = iso * Vector3::y();
    /// assert_relative_eq!(rotated, Vector3::z(), epsilon = 1e-10);
    /// ```
    fn from_rx(angle: f64) -> Iso3;

    /// Create an isometry that rotates around the y-axis by a given angle. When the y-axis is
    /// pointed at the viewer, positive angles will produce rotations viewed as counter-clockwise.
    ///
    /// # Arguments
    ///
    /// * `angle`: angle of rotation, specified in radians
    ///
    /// returns: Isometry<f64, Unit<Quaternion<f64>>, 3>
    ///
    /// # Examples
    ///
    /// ```
    /// use std::f64::consts::PI;
    /// use approx::assert_relative_eq;
    /// use engeom::{Iso3, Vector3};
    /// use engeom::geom3::IsoExtensions3;
    ///
    /// let iso = Iso3::from_ry(PI / 2.0);
    /// let rotated = iso * Vector3::z();
    /// assert_relative_eq!(rotated, Vector3::x(), epsilon = 1e-10);
    /// ```
    fn from_ry(angle: f64) -> Iso3;

    /// Create an isometry that rotates around the z-axis by a given angle. When the z-axis is
    /// pointed at the viewer, positive angles will produce rotations viewed as counter-clockwise.
    ///
    /// # Arguments
    ///
    /// * `angle`: angle of rotation, specified in radians
    ///
    /// returns: Isometry<f64, Unit<Quaternion<f64>>, 3>
    ///
    /// # Examples
    ///
    /// ```
    /// use std::f64::consts::PI;
    /// use approx::assert_relative_eq;
    /// use engeom::{Iso3, Vector3};
    /// use engeom::geom3::IsoExtensions3;
    ///
    /// let iso = Iso3::from_rz(PI / 2.0);
    /// let rotated = iso * Vector3::x();
    /// assert_relative_eq!(rotated, Vector3::y(), epsilon = 1e-10);
    /// ```
    fn from_rz(angle: f64) -> Iso3;

    /// Return a copy of the isometry rotated by 180 degrees around its own x-axis. The location of
    /// the origin and the direction of its x-axis with respect to the global coordinate system
    /// are unchanged, but its y and z directions are reversed.
    ///
    /// # Examples
    ///
    /// ```
    /// use approx::assert_relative_eq;
    /// use engeom::{Iso3, Point3, Vector3};
    /// use engeom::geom3::IsoExtensions3;
    ///
    /// // A tilted, off-origin isometry, so its origin and axis directions don't coincide with
    /// // the global coordinate system and the effect of the flip is easy to see.
    /// let iso = Iso3::from_basis_xy(
    ///     &Vector3::new(1.0, 1.0, 1.0),
    ///     &Vector3::new(-1.0, 1.0, 1.0),
    ///     Some(Point3::new(1.0, 2.0, 3.0)),
    /// )
    /// .unwrap();
    /// let flipped = iso.flipped_around_x();
    ///
    /// assert_relative_eq!(iso.origin(), flipped.origin(), epsilon = 1e-6);
    /// assert_relative_eq!(iso.x(), flipped.x(), epsilon = 1e-6);
    /// assert_relative_eq!(iso.y(), -flipped.y(), epsilon = 1e-6);
    /// assert_relative_eq!(iso.z(), -flipped.z(), epsilon = 1e-6);
    /// ```
    fn flipped_around_x(&self) -> Iso3;

    /// Return a copy of the isometry rotated by 180 degrees around its own y-axis. The location of
    /// the origin and the direction of its y-axis with respect to the global coordinate system are
    /// unchanged, but its x and z directions are reversed.
    ///
    /// # Examples
    ///
    /// ```
    /// use approx::assert_relative_eq;
    /// use engeom::{Iso3, Point3, Vector3};
    /// use engeom::geom3::IsoExtensions3;
    ///
    /// // A tilted, off-origin isometry, so its origin and axis directions don't coincide with
    /// // the global coordinate system and the effect of the flip is easy to see.
    /// let iso = Iso3::from_basis_xy(
    ///     &Vector3::new(1.0, 1.0, 1.0),
    ///     &Vector3::new(-1.0, 1.0, 1.0),
    ///     Some(Point3::new(1.0, 2.0, 3.0)),
    /// )
    /// .unwrap();
    /// let flipped = iso.flipped_around_y();
    ///
    /// assert_relative_eq!(iso.origin(), flipped.origin(), epsilon = 1e-6);
    /// assert_relative_eq!(iso.x(), -flipped.x(), epsilon = 1e-6);
    /// assert_relative_eq!(iso.y(), flipped.y(), epsilon = 1e-6);
    /// assert_relative_eq!(iso.z(), -flipped.z(), epsilon = 1e-6);
    /// ```
    fn flipped_around_y(&self) -> Iso3;

    /// Return a copy of the isometry rotated by 180 degrees around its own z-axis. The location of
    /// the origin and the direction of its z-axis with respect to the global coordinate system
    /// are unchanged, but its x and y directions are reversed.
    ///
    /// # Examples
    ///
    /// ```
    /// use approx::assert_relative_eq;
    /// use engeom::{Iso3, Point3, Vector3};
    /// use engeom::geom3::IsoExtensions3;
    ///
    /// // A tilted, off-origin isometry, so its origin and axis directions don't coincide with
    /// // the global coordinate system and the effect of the flip is easy to see.
    /// let iso = Iso3::from_basis_xy(
    ///     &Vector3::new(1.0, 1.0, 1.0),
    ///     &Vector3::new(-1.0, 1.0, 1.0),
    ///     Some(Point3::new(1.0, 2.0, 3.0)),
    /// )
    /// .unwrap();
    /// let flipped = iso.flipped_around_z();
    ///
    /// assert_relative_eq!(iso.origin(), flipped.origin(), epsilon = 1e-6);
    /// assert_relative_eq!(iso.x(), -flipped.x(), epsilon = 1e-6);
    /// assert_relative_eq!(iso.y(), -flipped.y(), epsilon = 1e-6);
    /// assert_relative_eq!(iso.z(), flipped.z(), epsilon = 1e-6);
    /// ```
    fn flipped_around_z(&self) -> Iso3;

    /// Return the location of the isometry's origin in the global coordinate system. This is what
    /// you get when you transform the point (0, 0, 0) by this isometry.
    ///
    /// # Examples
    ///
    /// ```
    /// use approx::assert_relative_eq;
    /// use engeom::{Iso3, Point3};
    /// use engeom::geom3::IsoExtensions3;
    ///
    /// let iso = Iso3::from_translation(1.0, 2.0, 3.0);
    /// assert_relative_eq!(iso.origin(), Point3::new(1.0, 2.0, 3.0), epsilon = 1e-10);
    /// ```
    fn origin(&self) -> Point3;

    /// Return the direction of the isometry's x-axis in the global coordinate system. This is what
    /// you get when you transform the unit vector (1, 0, 0) by this isometry.
    ///
    /// # Examples
    ///
    /// ```
    /// use std::f64::consts::PI;
    /// use approx::assert_relative_eq;
    /// use engeom::{Iso3, Vector3};
    /// use engeom::geom3::IsoExtensions3;
    ///
    /// let iso = Iso3::from_rz(PI / 2.0);
    /// assert_relative_eq!(iso.x(), Vector3::y_axis(), epsilon = 1e-10);
    /// ```
    fn x(&self) -> UnitVec3;

    /// Return the direction of the isometry's y-axis in the global coordinate system. This is what
    /// you get when you transform the unit vector (0, 1, 0) by this isometry.
    ///
    /// # Examples
    ///
    /// ```
    /// use std::f64::consts::PI;
    /// use approx::assert_relative_eq;
    /// use engeom::{Iso3, Vector3};
    /// use engeom::geom3::IsoExtensions3;
    ///
    /// let iso = Iso3::from_rx(PI / 2.0);
    /// assert_relative_eq!(iso.y(), Vector3::z_axis(), epsilon = 1e-10);
    /// ```
    fn y(&self) -> UnitVec3;

    /// Return the direction of the isometry's z-axis in the global coordinate system. This is what
    /// you get when you transform the unit vector (0, 0, 1) by this isometry.
    ///
    /// # Examples
    ///
    /// ```
    /// use std::f64::consts::PI;
    /// use approx::assert_relative_eq;
    /// use engeom::{Iso3, Vector3};
    /// use engeom::geom3::IsoExtensions3;
    ///
    /// let iso = Iso3::from_ry(PI / 2.0);
    /// assert_relative_eq!(iso.z(), Vector3::x_axis(), epsilon = 1e-10);
    /// ```
    fn z(&self) -> UnitVec3;
}

impl IsoExtensions3 for Iso3 {
    fn from_translation(x: f64, y: f64, z: f64) -> Iso3 {
        Iso3::translation(x, y, z)
    }

    fn from_rotation(axisangle: &Vector3) -> Iso3 {
        Iso3::rotation(*axisangle)
    }

    fn from_array(array: &[f64; 16]) -> Result<Self> {
        try_convert(Matrix4::from_row_slice(array)).ok_or("Could not convert to Iso3".into())
    }

    fn from_z_arbitrary_xy(z: &UnitVec3, origin: Option<Point3>) -> Iso3 {
        let n = z.into_inner();
        let reference = if n.z.abs() < 0.9 {
            Vector3::z()
        } else {
            Vector3::x()
        };
        let x_axis = reference.cross(&n).normalize();
        let y_axis = n.cross(&x_axis);

        let rot_m = Matrix3::from_columns(&[x_axis, y_axis, n]);
        let r = UnitQuaternion::from_matrix(&rot_m);
        let t = if let Some(o) = origin {
            Translation3::from(o.coords)
        } else {
            Translation3::identity()
        };

        Iso3::from_parts(t, r)
    }

    fn from_rot_axis(axis: &Line3, angle: f64) -> Result<Iso3> {
        let dir =
            UnitVec3::try_new(axis.direction, 1e-10).ok_or("Could not normalize axis direction")?;
        let r = UnitQuaternion::from_axis_angle(&dir, angle);
        let t = axis.origin.coords - r * axis.origin.coords;
        Ok(Iso3::from_parts(Translation3::from(t), r))
    }

    fn from_basis_xy(e0: &Vector3, e1: &Vector3, origin: Option<Point3>) -> Result<Iso3> {
        let e0 = e0.try_normalize(1e-10).ok_or("Could not normalize e0")?;
        let e2 = e0
            .cross(e1)
            .try_normalize(1e-10)
            .ok_or("Could not normalize e2")?;
        let e1 = e2
            .cross(&e0)
            .try_normalize(1e-10)
            .ok_or("Could not normalize e1")?;

        from_bases(e0, e1, e2, origin)
    }

    fn from_basis_xz(e0: &Vector3, e2: &Vector3, origin: Option<Point3>) -> Result<Iso3> {
        let e0 = e0.try_normalize(1e-10).ok_or("Could not normalize e0")?;
        let e1 = e2
            .cross(&e0)
            .try_normalize(1e-10)
            .ok_or("Could not normalize e1")?;
        let e2 = e0
            .cross(&e1)
            .try_normalize(1e-10)
            .ok_or("Could not normalize e2")?;
        from_bases(e0, e1, e2, origin)
    }

    fn from_basis_yz(e1: &Vector3, e2: &Vector3, origin: Option<Point3>) -> Result<Iso3> {
        let e1 = e1.try_normalize(1e-10).ok_or("Could not normalize e1")?;
        let e0 = e1
            .cross(e2)
            .try_normalize(1e-10)
            .ok_or("Could not normalize e0")?;
        let e2 = e0
            .cross(&e1)
            .try_normalize(1e-10)
            .ok_or("Could not normalize e2")?;
        from_bases(e0, e1, e2, origin)
    }

    fn from_basis_yx(e1: &Vector3, e0: &Vector3, origin: Option<Point3>) -> Result<Iso3> {
        let e1 = e1.try_normalize(1e-10).ok_or("Could not normalize e1")?;
        let e2 = e0
            .cross(&e1)
            .try_normalize(1e-10)
            .ok_or("Could not normalize e2")?;
        let e0 = e1
            .cross(&e2)
            .try_normalize(1e-10)
            .ok_or("Could not normalize e0")?;
        from_bases(e0, e1, e2, origin)
    }

    fn from_basis_zx(e2: &Vector3, e0: &Vector3, origin: Option<Point3>) -> Result<Iso3> {
        let e2 = e2.try_normalize(1e-10).ok_or("Could not normalize e2")?;
        let e1 = e2
            .cross(e0)
            .try_normalize(1e-10)
            .ok_or("Could not normalize e2")?;
        let e0 = e1
            .cross(&e2)
            .try_normalize(1e-10)
            .ok_or("Could not normalize e0")?;
        from_bases(e0, e1, e2, origin)
    }

    fn from_basis_zy(e2: &Vector3, e1: &Vector3, origin: Option<Point3>) -> Result<Iso3> {
        let e2 = e2.try_normalize(1e-10).ok_or("Could not normalize e2")?;
        let e0 = e1
            .cross(&e2)
            .try_normalize(1e-10)
            .ok_or("Could not normalize e0")?;
        let e1 = e2
            .cross(&e0)
            .try_normalize(1e-10)
            .ok_or("Could not normalize e2")?;
        from_bases(e0, e1, e2, origin)
    }

    fn from_rx(angle: f64) -> Iso3 {
        Iso3::rotation(Vector3::x() * angle)
    }

    fn from_ry(angle: f64) -> Iso3 {
        Iso3::rotation(Vector3::y() * angle)
    }

    fn from_rz(angle: f64) -> Iso3 {
        Iso3::rotation(Vector3::z() * angle)
    }

    fn flipped_around_x(&self) -> Self {
        self * Iso3::rotation(Vector3::x() * PI)
    }

    fn flipped_around_y(&self) -> Self {
        self * Iso3::rotation(Vector3::y() * PI)
    }

    fn flipped_around_z(&self) -> Self {
        self * Iso3::rotation(Vector3::z() * PI)
    }

    fn origin(&self) -> Point3 {
        self * Point3::origin()
    }

    fn x(&self) -> UnitVec3 {
        self * Vector3::x_axis()
    }

    fn y(&self) -> UnitVec3 {
        self * Vector3::y_axis()
    }

    fn z(&self) -> UnitVec3 {
        self * Vector3::z_axis()
    }
}

fn from_bases(e0: Vector3, e1: Vector3, e2: Vector3, origin: Option<Point3>) -> Result<Iso3> {
    let rot_m = Matrix3::from_columns(&[e0, e1, e2]);
    let r = UnitQuaternion::from_matrix(&rot_m);
    let t = if let Some(o) = origin {
        Translation3::from(o.coords)
    } else {
        Translation3::identity()
    };

    Ok(Iso3::from_parts(t, r))
}

#[cfg(test)]
mod tests {
    use super::*;
    use crate::{Point3, UnitVec3};
    use approx::assert_relative_eq;
    use std::f64::consts::PI;

    struct BasisCheck {
        o: Point3,
        e0: Vector3,
        e1: Vector3,
        e2: Vector3,
        fwd: Iso3,
    }

    impl BasisCheck {
        fn new() -> Self {
            let o = Point3::new(1.0, 2.0, 3.0);
            let angle = UnitVec3::new_normalize(Vector3::new(1.0, 1.0, 1.0));
            let fwd = Iso3::from_parts(
                Translation3::from(o.coords),
                UnitQuaternion::new(PI / 4.0 * angle.into_inner()),
            );
            let e0 = fwd * Vector3::x();
            let e1 = fwd * Vector3::y();
            let e2 = fwd * Vector3::z();

            Self { o, e0, e1, e2, fwd }
        }
    }

    #[test]
    fn from_basis_xy() -> Result<()> {
        let check = BasisCheck::new();
        let iso = Iso3::from_basis_xy(&check.e0, &check.e1, Some(check.o))?;
        assert_relative_eq!(iso, check.fwd, epsilon = 1e-6);
        Ok(())
    }

    #[test]
    fn from_basis_xz() -> Result<()> {
        let check = BasisCheck::new();
        let iso = Iso3::from_basis_xz(&check.e0, &check.e2, Some(check.o))?;
        assert_relative_eq!(iso, check.fwd, epsilon = 1e-6);
        Ok(())
    }

    #[test]
    fn from_basis_yx() -> Result<()> {
        let check = BasisCheck::new();
        let iso = Iso3::from_basis_yx(&check.e1, &check.e0, Some(check.o))?;
        assert_relative_eq!(iso, check.fwd, epsilon = 1e-6);
        Ok(())
    }

    #[test]
    fn from_basis_yz() -> Result<()> {
        let check = BasisCheck::new();
        let iso = Iso3::from_basis_yz(&check.e1, &check.e2, Some(check.o))?;
        assert_relative_eq!(iso, check.fwd, epsilon = 1e-6);
        Ok(())
    }

    #[test]
    fn from_basis_zx() -> Result<()> {
        let check = BasisCheck::new();
        let iso = Iso3::from_basis_zx(&check.e2, &check.e0, Some(check.o))?;
        assert_relative_eq!(iso, check.fwd, epsilon = 1e-6);
        Ok(())
    }

    #[test]
    fn from_basis_zy() -> Result<()> {
        let check = BasisCheck::new();
        let iso = Iso3::from_basis_zy(&check.e2, &check.e1, Some(check.o))?;
        assert_relative_eq!(iso, check.fwd, epsilon = 1e-6);
        Ok(())
    }

    #[test]
    fn from_basis_xy_manual() {
        let o = Point3::new(1.0, 2.0, 3.0);
        let e0 = UnitVec3::new_normalize(Vector3::new(1.0, 1.0, 0.0));
        let e1 = Vector3::new(0.0, 1.0, 1.0);

        let iso = Iso3::from_basis_xy(&e0.into_inner(), &e1, Some(o)).unwrap();

        assert_relative_eq!(iso * Point3::origin(), o, epsilon = 1e-6);
        assert_relative_eq!(
            iso * Point3::new(1.0, 0.0, 0.0),
            o + e0.into_inner() * 1.0,
            epsilon = 1e-6
        );
    }

    #[test]
    fn from_translation_matches_nalgebra() {
        let iso = Iso3::from_translation(1.0, 2.0, 3.0);

        assert_relative_eq!(
            iso * Point3::origin(),
            Point3::new(1.0, 2.0, 3.0),
            epsilon = 1e-10
        );
        assert_relative_eq!(iso, Iso3::translation(1.0, 2.0, 3.0), epsilon = 1e-10);
    }

    #[test]
    fn from_rotation_matches_nalgebra() {
        let axisangle = Vector3::z() * (PI / 2.0);
        let iso = Iso3::from_rotation(&axisangle);

        assert_relative_eq!(iso * Vector3::x(), Vector3::y(), epsilon = 1e-10);
        assert_relative_eq!(iso, Iso3::rotation(axisangle), epsilon = 1e-10);

        // The magnitude of the vector carries the angle, so an arbitrary axis should agree with
        // the equivalent axis-and-angle construction.
        let axis = UnitVec3::new_normalize(Vector3::new(1.0, 2.0, 3.0));
        let iso = Iso3::from_rotation(&(axis.into_inner() * (PI / 3.0)));
        assert_relative_eq!(
            iso,
            Iso3::from_parts(
                Translation3::identity(),
                UnitQuaternion::from_axis_angle(&axis, PI / 3.0)
            ),
            epsilon = 1e-10
        );
    }

    #[test]
    fn from_array_simple() {
        let array = [
            1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 2.0, 0.0, 0.0, 1.0, 3.0, 0.0, 0.0, 0.0, 1.0,
        ];
        let iso = Iso3::from_array(&array).unwrap();
        let m = iso.to_matrix();
        let expected = Matrix4::new(
            1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 2.0, 0.0, 0.0, 1.0, 3.0, 0.0, 0.0, 0.0, 1.0,
        );
        assert_relative_eq!(m, expected);
    }

    #[test]
    fn flip_x_semantics() {
        let iso = flip_cs();
        let flipped = iso.flipped_around_x();

        assert_relative_eq!(iso.origin(), flipped.origin(), epsilon = 1e-6);
        assert_relative_eq!(iso.x(), flipped.x(), epsilon = 1e-6);
        assert_relative_eq!(iso.y(), -flipped.y(), epsilon = 1e-6);
        assert_relative_eq!(iso.z(), -flipped.z(), epsilon = 1e-6);
    }

    #[test]
    fn flip_y_semantics() {
        let iso = flip_cs();
        let flipped = iso.flipped_around_y();

        assert_relative_eq!(iso.origin(), flipped.origin(), epsilon = 1e-6);
        assert_relative_eq!(iso.x(), -flipped.x(), epsilon = 1e-6);
        assert_relative_eq!(iso.y(), flipped.y(), epsilon = 1e-6);
        assert_relative_eq!(iso.z(), -flipped.z(), epsilon = 1e-6);
    }

    #[test]
    fn flip_z_semantics() {
        let iso = flip_cs();
        let flipped = iso.flipped_around_z();

        assert_relative_eq!(iso.origin(), flipped.origin(), epsilon = 1e-6);
        assert_relative_eq!(iso.x(), -flipped.x(), epsilon = 1e-6);
        assert_relative_eq!(iso.y(), -flipped.y(), epsilon = 1e-6);
        assert_relative_eq!(iso.z(), flipped.z(), epsilon = 1e-6);
    }

    fn flip_cs() -> Iso3 {
        Iso3::from_basis_xy(
            &Vector3::new(1.0, 1.0, 1.0),
            &Vector3::new(-1.0, 1.0, 1.0),
            Some(Point3::new(1.0, 2.0, 3.0)),
        )
        .unwrap()
    }

    #[test]
    fn rotation_axis() {
        let axis = Line3::new(Point3::new(1.0, 1.0, 0.0), Vector3::z());
        let test = Point3::new(2.0, 1.0, 0.0);
        let expected = Point3::new(1.0, 2.0, 0.0);

        let iso = Iso3::from_rot_axis(&axis, PI / 2.0).unwrap();
        let result = iso * test;
        assert_relative_eq!(result, expected, epsilon = 1e-6);
    }
}