Exemplo n.º 1
0
        public void DirectionsTest(string p1s, string p2s, string evs)
        {
            Line3D l         = Line3D.Parse(p1s, p2s);
            var    excpected = UnitVector3D.Parse(evs);

            AssertGeometry.AreEqual(excpected, l.Direction);
        }
Exemplo n.º 2
0
        public void Normalize(string vs, string evs)
        {
            var v1       = Vector2D.Parse(vs);
            var expected = Vector2D.Parse(evs);

            AssertGeometry.AreEqual(expected, v1.Normalize());
        }
Exemplo n.º 3
0
        public void CoordinateSystemBinaryFormatter()
        {
            var cs     = new CoordinateSystem(new Point3D(1, -2, 3), new Vector3D(0, 1, 0), new Vector3D(0, 0, 1), new Vector3D(1, 0, 0));
            var result = this.BinaryFormmaterRoundTrip(cs);

            AssertGeometry.AreEqual(cs, result);
        }
Exemplo n.º 4
0
        public void Parse(string rs, string eps, string evs)
        {
            var ray = Ray3D.Parse(rs);

            AssertGeometry.AreEqual(Point3D.Parse(eps), ray.ThroughPoint);
            AssertGeometry.AreEqual(Vector3D.Parse(evs), ray.Direction);
        }
Exemplo n.º 5
0
        public void Multiply(string vectorAsString, double mulitplier, string expected)
        {
            var vector = Vector3D.Parse(vectorAsString);

            AssertGeometry.AreEqual(Vector3D.Parse(expected), mulitplier * vector, 1e-6);
            AssertGeometry.AreEqual(Vector3D.Parse(expected), mulitplier * vector, 1e-6);
        }
Exemplo n.º 6
0
        public void ParseTest(string vs, double[] ep)
        {
            Vector3D point3D  = Vector3D.Parse(vs);
            Vector3D expected = new Vector3D(ep);

            AssertGeometry.AreEqual(point3D, expected, 1e-9);
        }
Exemplo n.º 7
0
        public void Scale(string vs, double s, string evs)
        {
            var      v      = Vector3D.Parse(vs);
            Vector3D actual = v.ScaleBy(s);

            AssertGeometry.AreEqual(Vector3D.Parse(evs), actual, 1e-6);
        }
Exemplo n.º 8
0
        public void ParseTest(string pointAsString, double[] expectedPoint)
        {
            Point3D point3D  = Point3D.Parse(pointAsString);
            Point3D expected = new Point3D(expectedPoint);

            AssertGeometry.AreEqual(expected, point3D, 1e-9);
        }
Exemplo n.º 9
0
        public void PolarCtorTest(int r, string avs, string eps)
        {
            var av = Angle.Parse(avs);
            var p  = new Vector2D(r, av);
            var ep = Vector2D.Parse(eps);

            AssertGeometry.AreEqual(ep, p, 1e-2);
        }
Exemplo n.º 10
0
        public void ToString(string vs, string format, string expected, double tolerance)
        {
            var    v      = UnitVector3D.Parse(vs);
            string actual = v.ToString(format);

            Assert.AreEqual(expected, actual);
            AssertGeometry.AreEqual(v, UnitVector3D.Parse(actual), tolerance);
        }
Exemplo n.º 11
0
        public void Ray3DBinaryFormatter(string ps, string vs, bool asElements)
        {
            var ray    = new Ray3D(Point3D.Parse(ps), UnitVector3D.Parse(vs));
            var result = this.BinaryFormmaterRoundTrip(ray);

            Assert.AreEqual(ray, result);
            AssertGeometry.AreEqual(ray, result, 1e-6);
        }
Exemplo n.º 12
0
        public void Normalize(string vs, string evs)
        {
            var vector   = Vector3D.Parse(vs);
            var uv       = vector.Normalize();
            var expected = UnitVector3D.Parse(evs);

            AssertGeometry.AreEqual(expected, uv, 1E-6);
        }
Exemplo n.º 13
0
        public void ToString(string vs, string format, string expected, double tolerance)
        {
            var    p      = Point3D.Parse(vs);
            string actual = p.ToString(format);

            Assert.AreEqual(expected, actual);
            AssertGeometry.AreEqual(p, Point3D.Parse(actual), tolerance);
        }
Exemplo n.º 14
0
        public void ProjectPointOnTest(string ps, string pls, string eps)
        {
            var plane          = Plane.Parse(pls);
            var projectedPoint = plane.Project(Point3D.Parse(ps));
            var expected       = Point3D.Parse(eps);

            AssertGeometry.AreEqual(expected, projectedPoint, float.Epsilon);
        }
Exemplo n.º 15
0
        public void XmlTests(string p1s, string p2s, string xml)
        {
            Point3D p1 = Point3D.Parse(p1s);
            Point3D p2 = Point3D.Parse(p2s);
            var     l  = new Line3D(p1, p2);

            AssertXml.XmlRoundTrips(l, xml, (e, a) => AssertGeometry.AreEqual(e, a));
        }
Exemplo n.º 16
0
        public void TransformUnitVector()
        {
            var cs     = CoordinateSystem.Rotation(90, AngleUnit.Degrees, UnitVector3D.ZAxis);
            var uv     = UnitVector3D.XAxis;
            var actual = cs.Transform(uv);

            AssertGeometry.AreEqual(UnitVector3D.YAxis, actual);
        }
Exemplo n.º 17
0
        public void MirrorPointTest()
        {
            var     plane       = new Plane(UnitVector3D.ZAxis, new Point3D(0, 0, 0));
            var     point3D     = new Point3D(1, 2, 3);
            Point3D mirrorAbout = plane.MirrorAbout(point3D);

            AssertGeometry.AreEqual(new Point3D(1, 2, -3), mirrorAbout, float.Epsilon);
        }
Exemplo n.º 18
0
        public void CrossProductTest(string v1s, string v2s, string ves)
        {
            var      vector1      = Vector3D.Parse(v1s);
            var      vector2      = Vector3D.Parse(v2s);
            var      expected     = Vector3D.Parse(ves);
            Vector3D crossProduct = vector1.CrossProduct(vector2);

            AssertGeometry.AreEqual(expected, crossProduct, 1E-6);
        }
Exemplo n.º 19
0
        public void RotateTest(string vs, string avs, double deg, string evs)
        {
            var v           = Vector3D.Parse(vs);
            var aboutvector = Vector3D.Parse(avs);
            var rotated     = v.Rotate(aboutvector, Angle.FromDegrees(deg));
            var expected    = Vector3D.Parse(evs);

            AssertGeometry.AreEqual(expected, rotated, 1E-6);
        }
Exemplo n.º 20
0
        public void ParseTests(string s, double[] ops, double[] xs, double[] ys, double[] zs)
        {
            var cs = CoordinateSystem.Parse(s);

            AssertGeometry.AreEqual(new Point3D(ops), cs.Origin);
            AssertGeometry.AreEqual(new Vector3D(xs), cs.XAxis);
            AssertGeometry.AreEqual(new Vector3D(ys), cs.YAxis);
            AssertGeometry.AreEqual(new Vector3D(zs), cs.ZAxis);
        }
Exemplo n.º 21
0
        public void LineToTest()
        {
            var    ray      = new Ray3D(new Point3D(0, 0, 0), UnitVector3D.ZAxis);
            var    point3D  = new Point3D(1, 0, 0);
            Line3D line3DTo = ray.LineTo(point3D);

            AssertGeometry.AreEqual(new Point3D(0, 0, 0), line3DTo.StartPoint);
            AssertGeometry.AreEqual(point3D, line3DTo.EndPoint, float.Epsilon);
        }
Exemplo n.º 22
0
        public void TransformPoint(string ps, string eps, string css)
        {
            var p = Point3D.Parse(ps);
            CoordinateSystem cs     = CoordinateSystem.Parse(css);
            Point3D          actual = p.TransformBy(cs);
            var expected            = Point3D.Parse(eps);

            AssertGeometry.AreEqual(expected, actual, float.Epsilon);
        }
Exemplo n.º 23
0
        public void Transform(string cs1s, string cs2s)
        {
            var cs1      = CoordinateSystem.Parse(cs1s);
            var cs2      = CoordinateSystem.Parse(cs2s);
            var actual   = cs1.Transform(cs2);
            var expected = new CoordinateSystem(cs1.Multiply(cs2));

            AssertGeometry.AreEqual(expected, actual);
        }
Exemplo n.º 24
0
        public void TransformVector(string vs, string evs, string css)
        {
            var v = Vector3D.Parse(vs);
            CoordinateSystem cs     = CoordinateSystem.Parse(css);
            Vector3D         actual = cs.Transform(v);
            var expected            = Vector3D.Parse(evs);

            AssertGeometry.AreEqual(expected, actual);
        }
Exemplo n.º 25
0
        public void Translation(string ps, string vs, string eps)
        {
            var p  = Point3D.Parse(ps);
            var cs = CoordinateSystem.Translation(Vector3D.Parse(vs));
            var tp = cs.Transform(p);

            Console.WriteLine(cs.ToString());
            AssertGeometry.AreEqual(Point3D.Parse(eps), tp);
        }
Exemplo n.º 26
0
        public void CtorTest()
        {
            var plane1 = new Plane(new Point3D(0, 0, 3), UnitVector3D.ZAxis);
            var plane2 = new Plane(0, 0, 3, -3);
            var plane3 = new Plane(UnitVector3D.ZAxis, 3);

            AssertGeometry.AreEqual(plane1, plane2);
            AssertGeometry.AreEqual(plane1, plane3);
        }
Exemplo n.º 27
0
        public void IntersectionOf(string pl1s, string pl2s, string eps, string evs)
        {
            var plane1   = Plane.Parse(pl1s);
            var plane2   = Plane.Parse(pl2s);
            var actual   = Ray3D.IntersectionOf(plane1, plane2);
            var expected = Ray3D.Parse(eps, evs);

            AssertGeometry.AreEqual(expected, actual);
        }
Exemplo n.º 28
0
        public void ProjectOn(string p1s, string p2s, string pls, string ep1s, string ep2s)
        {
            var p1       = Point3D.Parse(p1s);
            var p2       = Point3D.Parse(p2s);
            var line     = new Line3D(p1, p2);
            var plane    = Plane.Parse(pls);
            var expected = new Line3D(Point3D.Parse(ep1s), Point3D.Parse(ep2s));

            AssertGeometry.AreEqual(expected, line.ProjectOn(plane));
        }
Exemplo n.º 29
0
        public void ProjectOnTests(string ps, string pls, string eps)
        {
            var p      = Point3D.Parse(ps);
            var p2     = Plane.Parse(pls);
            var actual = p.ProjectOn(p2);

            var ep = Point3D.Parse(eps);

            AssertGeometry.AreEqual(ep, actual);
        }
Exemplo n.º 30
0
        public void MirrorAbout(string ps, string pls, string eps)
        {
            var p      = Point3D.Parse(ps);
            var p2     = Plane.Parse(pls);
            var actual = p.MirrorAbout(p2);

            var ep = Point3D.Parse(eps);

            AssertGeometry.AreEqual(ep, actual);
        }