public void XmlRoundtrip()
        {
            var uv  = UnitVector3D.Create(0.2672612419124244, -0.53452248382484879, 0.80178372573727319);
            var xml = "<UnitVector3D X=\"0.2672612419124244\" Y=\"-0.53452248382484879\" Z=\"0.80178372573727319\" />";

            AssertXml.XmlRoundTrips(uv, xml, (expected, actual) => AssertGeometry.AreEqual(expected, actual));
        }
 public void ReadFrom(string xml)
 {
     using (var reader = new StringReader(xml))
     {
         var actual = UnitVector3D.ReadFrom(XmlReader.Create(reader));
         Assert.AreEqual(UnitVector3D.Create(0.2672612419124244, -0.53452248382484879, 0.80178372573727319), actual);
     }
 }
        public void XmlElements()
        {
            var v          = UnitVector3D.Create(0.2672612419124244, -0.53452248382484879, 0.80178372573727319);
            var serializer = new XmlSerializer(typeof(UnitVector3D));

            using (var reader = new StringReader("<UnitVector3D><X>0.2672612419124244</X><Y>-0.53452248382484879</Y><Z>0.80178372573727319</Z></UnitVector3D>"))
            {
                AssertGeometry.AreEqual(v, (UnitVector3D)serializer.Deserialize(reader));
            }
        }
        public void XmlContainerElements()
        {
            var xml = "<ContainerOfUnitVector3D>\r\n" +
                      "  <Value1><X>0.2672612419124244</X><Y>-0.53452248382484879</Y><Z>0.80178372573727319</Z></Value1>\r\n" +
                      "  <Value2><X>1</X><Y>0</Y><Z>0</Z></Value2>\r\n" +
                      "</ContainerOfUnitVector3D>";
            var serializer   = new XmlSerializer(typeof(AssertXml.Container <UnitVector3D>));
            var deserialized = (AssertXml.Container <UnitVector3D>)serializer.Deserialize(new StringReader(xml));

            AssertGeometry.AreEqual(UnitVector3D.Create(0.2672612419124244, -0.53452248382484879, 0.80178372573727319), deserialized.Value1);
            AssertGeometry.AreEqual(UnitVector3D.Create(1, 0, 0), deserialized.Value2);
        }
Exemple #5
0
        public void InterSectionPointDifferentOrder()
        {
            var plane1           = new Plane(UnitVector3D.Create(0.8, 0.3, 0.01), new Point3D(20, 0, 0));
            var plane2           = new Plane(UnitVector3D.Create(0.002, 1, 0.1), new Point3D(0, 0, 0));
            var plane3           = new Plane(UnitVector3D.Create(0.5, 0.5, 1), new Point3D(0, 0, -30));
            var pointFromPlanes1 = Plane.PointFromPlanes(plane1, plane2, plane3);
            var pointFromPlanes2 = Plane.PointFromPlanes(plane2, plane1, plane3);
            var pointFromPlanes3 = Plane.PointFromPlanes(plane3, plane1, plane2);

            AssertGeometry.AreEqual(pointFromPlanes1, pointFromPlanes2, 1E-10);
            AssertGeometry.AreEqual(pointFromPlanes3, pointFromPlanes2, 1E-10);
        }
        public void ToDenseVector()
        {
            var uv     = UnitVector3D.Create(0.2672612419124244, -0.53452248382484879, 0.80178372573727319);
            var vector = uv.ToVector();

            Assert.AreEqual(3, vector.Count);
            Assert.AreEqual(0.2672612419124244, vector[0]);
            Assert.AreEqual(-0.53452248382484879, vector[1]);
            Assert.AreEqual(0.80178372573727319, vector[2]);

            var roundtripped = UnitVector3D.OfVector(vector);

            Assert.AreEqual(0.2672612419124244, roundtripped.X);
            Assert.AreEqual(-0.53452248382484879, roundtripped.Y);
            Assert.AreEqual(0.80178372573727319, roundtripped.Z);
        }
        public void XmlContainerRoundtrip()
        {
            var container = new AssertXml.Container <UnitVector3D>
            {
                Value1 = UnitVector3D.Create(0.2672612419124244, -0.53452248382484879, 0.80178372573727319),
                Value2 = UnitVector3D.Create(1, 0, 0)
            };
            var expected = "<ContainerOfUnitVector3D>\r\n" +
                           "  <Value1 X=\"0.2672612419124244\" Y=\"-0.53452248382484879\" Z=\"0.80178372573727319\"></Value1>\r\n" +
                           "  <Value2 X=\"1\" Y=\"0\" Z=\"0\"></Value2>\r\n" +
                           "</ContainerOfUnitVector3D>";
            var roundTrip = AssertXml.XmlSerializerRoundTrip(container, expected);

            AssertGeometry.AreEqual(container.Value1, roundTrip.Value1);
            AssertGeometry.AreEqual(container.Value2, roundTrip.Value2);
        }
        public void Create()
        {
            var actual = UnitVector3D.Create(1, -2, 3);

            Assert.AreEqual(0.2672612419124244, actual.X);
            Assert.AreEqual(-0.53452248382484879, actual.Y);
            Assert.AreEqual(0.80178372573727319, actual.Z);

            actual = UnitVector3D.Create(0.2672612419124244, -0.53452248382484879, 0.80178372573727319);
            Assert.AreEqual(0.2672612419124244, actual.X);
            Assert.AreEqual(-0.53452248382484879, actual.Y);
            Assert.AreEqual(0.80178372573727319, actual.Z);

            Assert.Throws <ArgumentOutOfRangeException>(() => UnitVector3D.Create(double.NaN, 2, 3));
            Assert.Throws <ArgumentOutOfRangeException>(() => UnitVector3D.Create(double.PositiveInfinity, 2, 3));
            Assert.Throws <ArgumentOutOfRangeException>(() => UnitVector3D.Create(double.NegativeInfinity, 2, 3));
        }
 public UnitVector3D Create()
 {
     return(UnitVector3D.Create(1, 0, 0, 2));
 }