Ejemplo n.º 1
0
        public void RotateZ()
        {
            var rotMtx = Matrix3d.IDRotateZ(Math.PI * 0.5); //rotate 90 degrees
            var rotvec = rotMtx.Transform(testVectorX);

            Assert.AreEqual(0, rotvec.X, 1.5e-15, "X should be 0, \r The vector is: " + rotvec);
            Assert.AreEqual(-testVectorX.X, rotvec.Y, 1.5e-15, "Y should be " + (-testVectorY.X) + ", \r The vector is: " + rotvec);
            Assert.AreEqual(0, rotvec.Z, 1.5e-15, "Z should be 0, \r The vector is: " + rotvec);
        }
Ejemplo n.º 2
0
        public void MultiRotate()
        {
            var rotMtx1 = Matrix3d.IDRotateZ(Math.PI * 0.5);
            var rotMtx2 = Matrix3d.IDRotateZ(Math.PI * 0.5);
            var rotMtx  = rotMtx1 * rotMtx2;
            var rotvec  = rotMtx.Transform(testVectorX);


            Assert.AreEqual(-testVectorX.X, rotvec.X, 1.5e-15);
            Assert.AreEqual(0, rotvec.Y, 1.5e-15);
            Assert.AreEqual(0, rotvec.Z, 1.5e-15);
        }
Ejemplo n.º 3
0
        protected override void CreatePointArray()
        {
            _points = new PointD[_numberOfArcSegments + 1];

            var loAN    = -_orbitDB.LongitudeOfAscendingNode;
            var incl    = _orbitDB.Inclination;
            var mtxloan = Matrix3d.IDRotateZ(loAN);
            var mtxincl = Matrix3d.IDRotateX(incl);
            var mtxaop  = Matrix3d.IDRotateZ(_aop);

            //var mtx =  mtxaop * mtxincl * mtxloan;
            var    mtx   = mtxaop * mtxloan;
            double angle = 0;

            var coslop = 1 * Math.Cos(_loP_radians);
            var sinlop = 1 * Math.Sin(_loP_radians);

            //TODO: figure out propper matrix rotations for this, will be a bit more elegent.
            for (int i = 0; i < _numberOfArcSegments + 1; i++)
            {
                double x1 = SemiMaj * Math.Sin(angle) - _linearEccentricity;  //we add the focal distance so the focal point is "center"
                double y1 = SemiMinor * Math.Cos(angle);

                double x2 = (x1 * coslop) - (y1 * sinlop);
                double y2 = (x1 * sinlop) + (y1 * coslop);

                //Vector3 pnt = new Vector3(x1, y1, 0);
                //pnt = mtx.Transform(pnt);
                //Points[i] = new PointD() {X = pnt.X, Y = pnt.Y};
                _points[i] = new PointD()
                {
                    X = x2, Y = y2
                };
                angle += _segmentArcSweepRadians;
            }

            if (IsRetrogradeOrbit)
            {
                var mtxr1 = Matrix3d.IDRotateZ(-_loP_radians);
                var mtxr2 = Matrix3d.IDRotateZ(_loP_radians);
                var mtxr  = mtxr1 * mtxincl * mtxr2;
                for (int i = 0; i < _points.Length; i++)
                {
                    var pnt = mtxr.Transform(new Vector3(_points[i].X, _points[i].Y, 0));
                    _points[i] = new PointD()
                    {
                        X = pnt.X, Y = pnt.Y
                    };
                }
            }
            //TODO: try a Chaikins curve for this and increase the points depending on zoom and curviture.
        }
Ejemplo n.º 4
0
        void CreatePointArray()
        {
            var coslop = 1 * Math.Cos(LonditudeOfPeriapsis);
            var sinlop = 1 * Math.Sin(LonditudeOfPeriapsis);

            _points = new PointD[_numberOfArcSegments + 1];
            double angle = 0;

            for (int i = 0; i < _numberOfArcSegments + 1; i++)
            {
                double x1 = OrbitEllipseSemiMaj_m * Math.Sin(angle) - _linearEccentricity_m; //we add the focal distance so the focal point is "center"
                double y1 = OrbitEllipseSemiMinor_m * Math.Cos(angle);

                //rotates the points to allow for the LongditudeOfPeriapsis.
                double x2 = (x1 * coslop) - (y1 * sinlop);
                double y2 = (x1 * sinlop) + (y1 * coslop);
                _points[i] = new PointD()
                {
                    X = x2, Y = y2
                };
                angle += _segmentArcSweepRadians;
            }


            if (IsRetrogradeOrbit)
            {
                var mtxr1 = Matrix3d.IDRotateZ(-LonditudeOfPeriapsis);
                var mtxri = Matrix3d.IDRotateX(Math.PI);
                var mtxr2 = Matrix3d.IDRotateZ(LonditudeOfPeriapsis);

                var mtxr = mtxr1 * mtxri * mtxr2;
                for (int i = 0; i < _points.Length; i++)
                {
                    var pnt = mtxr.Transform(new Vector3(_points[i].X, _points[i].Y, 0));
                    _points[i] = new PointD()
                    {
                        X = pnt.X, Y = pnt.Y
                    };
                }
            }
        }