Exemple #1
0
        public void WindingOrderOnEllipsoid()
        {
            IList <Vector3D> positions = new List <Vector3D>();

            positions.Add(Ellipsoid.UnitSphere.ToVector3D(Trig.ToRadians(new Geodetic3D(0, 0))));
            positions.Add(Ellipsoid.UnitSphere.ToVector3D(Trig.ToRadians(new Geodetic3D(1, 0))));
            positions.Add(Ellipsoid.UnitSphere.ToVector3D(Trig.ToRadians(new Geodetic3D(1, 1))));

            EllipsoidTangentPlane  plane            = new EllipsoidTangentPlane(Ellipsoid.UnitSphere, positions);
            ICollection <Vector2D> positionsOnPlane = plane.ComputePositionsOnPlane(positions);

            Assert.AreEqual(PolygonWindingOrder.Counterclockwise, SimplePolygonAlgorithms.ComputeWindingOrder(positionsOnPlane));
        }
Exemple #2
0
        public void ComputeCurve2()
        {
            Vector3D p = -Vector3D.UnitZ;
            Vector3D q = -Vector3D.UnitY;

            IList <Vector3D> positions = Ellipsoid.UnitSphere.ComputeCurve(
                p, q, Trig.ToRadians(30));

            Assert.AreEqual(p, positions[0]);
            Assert.IsTrue(new Vector3D(0, -0.5, -0.866025403784439).Normalize().EqualsEpsilon(positions[1].Normalize(), 1e-10));
            Assert.IsTrue(new Vector3D(0, -0.866025403784439, -0.5).Normalize().EqualsEpsilon(positions[2].Normalize(), 1e-10));
            Assert.AreEqual(q, positions[3]);
        }
        public void Triangle()
        {
            IList <Vector3D> positions = new List <Vector3D>();

            positions.Add(Ellipsoid.UnitSphere.ToVector3D(Trig.ToRadians(new Geodetic3D(0, 0))));
            positions.Add(Ellipsoid.UnitSphere.ToVector3D(Trig.ToRadians(new Geodetic3D(1, 0))));
            positions.Add(Ellipsoid.UnitSphere.ToVector3D(Trig.ToRadians(new Geodetic3D(1, 1))));

            IndicesUnsignedInt indices = EarClippingOnEllipsoid.Triangulate(positions);

            Assert.AreEqual(3, indices.Values.Count);
            Assert.AreEqual(0, indices.Values[0]);
            Assert.AreEqual(1, indices.Values[1]);
            Assert.AreEqual(2, indices.Values[2]);
        }
        public void ComplexConcave()
        {
            IList <Vector3D> positions = new List <Vector3D>();

            positions.Add(Ellipsoid.UnitSphere.ToVector3D(Trig.ToRadians(new Geodetic3D(0, 0))));
            positions.Add(Ellipsoid.UnitSphere.ToVector3D(Trig.ToRadians(new Geodetic3D(2, 0))));
            positions.Add(Ellipsoid.UnitSphere.ToVector3D(Trig.ToRadians(new Geodetic3D(2, 1))));
            positions.Add(Ellipsoid.UnitSphere.ToVector3D(Trig.ToRadians(new Geodetic3D(0.1, 1.5))));
            positions.Add(Ellipsoid.UnitSphere.ToVector3D(Trig.ToRadians(new Geodetic3D(2, 2))));
            positions.Add(Ellipsoid.UnitSphere.ToVector3D(Trig.ToRadians(new Geodetic3D(0, 2))));
            positions.Add(Ellipsoid.UnitSphere.ToVector3D(Trig.ToRadians(new Geodetic3D(0, 1))));
            positions.Add(Ellipsoid.UnitSphere.ToVector3D(Trig.ToRadians(new Geodetic3D(1.9, 0.5))));

            IndicesUnsignedInt indices = EarClippingOnEllipsoid.Triangulate(positions);

            Assert.AreEqual(18, indices.Values.Count);
            Assert.AreEqual(3, indices.Values[0]);
            Assert.AreEqual(4, indices.Values[1]);
            Assert.AreEqual(5, indices.Values[2]);

            Assert.AreEqual(3, indices.Values[3]);
            Assert.AreEqual(5, indices.Values[4]);
            Assert.AreEqual(6, indices.Values[5]);

            Assert.AreEqual(3, indices.Values[6]);
            Assert.AreEqual(6, indices.Values[7]);
            Assert.AreEqual(7, indices.Values[8]);

            Assert.AreEqual(7, indices.Values[9]);
            Assert.AreEqual(0, indices.Values[10]);
            Assert.AreEqual(1, indices.Values[11]);

            Assert.AreEqual(7, indices.Values[12]);
            Assert.AreEqual(1, indices.Values[13]);
            Assert.AreEqual(2, indices.Values[14]);

            Assert.AreEqual(2, indices.Values[15]);
            Assert.AreEqual(3, indices.Values[16]);
            Assert.AreEqual(7, indices.Values[17]);
        }
Exemple #5
0
        public void ToGeodetic3D()
        {
            Ellipsoid ellipsoid = new Ellipsoid(6378137.0, 6378137.0, 6356752.314245);

            Vector3D   v = ellipsoid.ToVector3D(new Geodetic3D(0, 0, 0));
            Geodetic3D g = ellipsoid.ToGeodetic3D(v);

            Assert.AreEqual(0.0, g.Longitude, 1e-10);
            Assert.AreEqual(0.0, g.Latitude, 1e-8);
            Assert.AreEqual(0.0, g.Height, 1e-10);

            v = ellipsoid.ToVector3D(new Geodetic3D(Trig.ToRadians(45.0), Trig.ToRadians(-60.0), -123.4));
            g = ellipsoid.ToGeodetic3D(v);
            Assert.AreEqual(Trig.ToRadians(45.0), g.Longitude, 1e-10);
            Assert.AreEqual(Trig.ToRadians(-60.0), g.Latitude, 1e-3);
            Assert.AreEqual(-123.4, g.Height, 1e-3);

            v = ellipsoid.ToVector3D(new Geodetic3D(Trig.ToRadians(-97.3), Trig.ToRadians(71.2), 1188.7));
            g = ellipsoid.ToGeodetic3D(v);
            Assert.AreEqual(Trig.ToRadians(-97.3), g.Longitude, 1e-10);
            Assert.AreEqual(Trig.ToRadians(71.2), g.Latitude, 1e-3);
            Assert.AreEqual(1188.7, g.Height, 1e-3);
        }
Exemple #6
0
        public void TwoTriangles3()
        {
            Vector3D[] positions = new Vector3D[]
            {
                Ellipsoid.UnitSphere.ToVector3D(Trig.ToRadians(new Geodetic2D(0, 44))),
                Ellipsoid.UnitSphere.ToVector3D(Trig.ToRadians(new Geodetic2D(1, 45))),
                Ellipsoid.UnitSphere.ToVector3D(Trig.ToRadians(new Geodetic2D(-1, 45))),
                Ellipsoid.UnitSphere.ToVector3D(Trig.ToRadians(new Geodetic2D(0, 46)))
            };

            IndicesUnsignedInt indices = new IndicesUnsignedInt();

            indices.Values.Add(0);
            indices.Values.Add(1);
            indices.Values.Add(2);
            indices.Values.Add(3);
            indices.Values.Add(2);
            indices.Values.Add(1);

            TriangleMeshSubdivisionResult result = TriangleMeshSubdivision.Compute(positions, indices, Trig.ToRadians(1.4));

            Assert.AreEqual(5, result.Positions.Count);
            Assert.AreEqual(12, result.Indices.Values.Count);
        }
Exemple #7
0
        public void TwoTriangles()
        {
            Vector3D[] positions = new Vector3D[]
            {
                Vector3D.Zero,
                new Vector3D(0.5, 0.5, 0),
                new Vector3D(-0.5, 0.5, 0),
                new Vector3D(0, 1, 0)
            };

            IndicesUnsignedInt indices = new IndicesUnsignedInt();

            indices.Values.Add(0);
            indices.Values.Add(1);
            indices.Values.Add(2);
            indices.Values.Add(3);
            indices.Values.Add(2);
            indices.Values.Add(1);

            TriangleMeshSubdivisionResult result = TriangleMeshSubdivision.Compute(positions, indices, Trig.ToRadians(90));

            Assert.AreEqual(0, result.Indices.Values[0]);
            Assert.AreEqual(1, result.Indices.Values[1]);
            Assert.AreEqual(2, result.Indices.Values[2]);

            Assert.AreEqual(3, result.Indices.Values[3]);
            Assert.AreEqual(2, result.Indices.Values[4]);
            Assert.AreEqual(1, result.Indices.Values[5]);
        }
Exemple #8
0
 public void OutOfRangeException()
 {
     TriangleMeshSubdivision.Compute(new Vector3D[] { }, new IndicesUnsignedInt(), Trig.ToRadians(1));
 }
Exemple #9
0
 public void Null2()
 {
     TriangleMeshSubdivision.Compute(new Vector3D[] { }, null, Trig.ToRadians(1));
 }
Exemple #10
0
 public void Null()
 {
     TriangleMeshSubdivision.Compute(null, new IndicesUnsignedInt(), Trig.ToRadians(1));
 }
Exemple #11
0
        public void ToVector3D()
        {
            Ellipsoid ellipsoid = new Ellipsoid(1, 1, 0.7);

            Assert.IsTrue(Vector3D.UnitX.EqualsEpsilon(ellipsoid.ToVector3D(new Geodetic3D(0, 0, 0)), 1e-10));
            Assert.IsTrue(Vector3D.UnitY.EqualsEpsilon(ellipsoid.ToVector3D(new Geodetic3D(Trig.ToRadians(90), 0, 0)), 1e-10));
            Assert.IsTrue(new Vector3D(0, 0, 0.7).EqualsEpsilon(ellipsoid.ToVector3D(new Geodetic3D(0, Trig.ToRadians(90), 0)), 1e-10));
        }