public void ApplyInvToPlaneXY_yields_a_Plane_passing_through_inverse_images_of_points_on_plane_XY_with_correct_orientation()
        {
            var x = new RotoTranslation3(new Rotation3(new Quaternion(1.1, -2.2, 3.3, -4.4)), new Vector3(4.1, -2.4, 1.3));

            var plane = x.ApplyInvToPlaneXY();

            Expect(x.ApplyInv(Vector3.Zero).DistanceTo(plane), Is.LessThan(_tolerance));
            Expect(x.ApplyInv(Vector3.UnitX).DistanceTo(plane), Is.LessThan(_tolerance));
            Expect(x.ApplyInv(Vector3.UnitY).DistanceTo(plane), Is.LessThan(_tolerance));

            Expect(x.ApplyInv(Vector3.UnitZ).SignedDistanceTo(plane), Is.Positive); // orientation test
        }
        public void Applying_inverse_RotoTranslation3_commutes_with_taking_PointAt_given_coordinate_from_Ray3()
        {
            var ray   = new Ray3(origin: new Vector3(3.141, 2.718, 0.577), direction: new Vector3(1.23, 4.56, -3.21));
            var trans = new RotoTranslation3(new Rotation3(new Quaternion(1.1, -2.2, 3.3, -4.4)), new Vector3(4.1, -2.4, 1.3));

            var coord = 5.77;

            var expected = trans.ApplyInv(ray.PointAt(coord));
            var actual   = trans.ApplyInv(ray).PointAt(coord);

            Expect(Vector3.Distance(actual, expected), Is.LessThan(_tolerance));
        }
        public void ApplyInv_to_Plane_given_in_parameteric_form_yields_a_Plane_passing_through_inverse_images_of_points_on_original_Plane_with_correct_orientation()
        {
            var x = new RotoTranslation3(new Rotation3(new Quaternion(1.1, -2.2, 3.3, -4.4)), new Vector3(4.1, -2.4, 1.3));

            var p = new Vector3(3.14, 2.88, 0.57);
            var u = new Vector3(-1, -2, 3);
            var v = new Vector3(-0.88, 0.49, 4.05);

            var origPlane = Plane.Parametric(p, u, v);

            var newPlane = x.ApplyInv(origPlane);

            Expect(x.ApplyInv(p).DistanceTo(newPlane), Is.LessThan(_tolerance));
            Expect(x.ApplyInv(p + u).DistanceTo(newPlane), Is.LessThan(_tolerance));
            Expect(x.ApplyInv(p + v).DistanceTo(newPlane), Is.LessThan(_tolerance));

            var q = new Vector3(0.17, -0.46, 0.83);

            Expect(x.ApplyInv(q).SignedDistanceTo(newPlane), Is.EqualTo(q.SignedDistanceTo(origPlane)).Within(_tolerance)); // orientation test
        }
 public static Segment3 ApplyInv(this RotoTranslation3 @this, Segment3 segment)
 {
     return(new Segment3(@this.ApplyInv(segment.Start), @this.ApplyInv(segment.End)));
 }
 public static Ray3 ApplyInv(this RotoTranslation3 @this, Ray3 ray)
 {
     return(new Ray3(@this.ApplyInv(ray.Origin), @this.Rotation.ApplyInv(ray.Direction)));
 }