Example #1
0
        public void RotateX()
        {
            var rotMtx = Matrix3d.IDRotateX(Math.PI * 0.5); //rotate 90 degrees
            var rotvec = rotMtx.Transform(testVectorZ);

            Assert.AreEqual(0, rotvec.X, 1.5e-15, "X should be 0, \r The vector is: " + rotvec);
            Assert.AreEqual(-testVectorZ.Z, rotvec.Y, 1.5e-15, "Y should be " + (-testVectorY.Z) + ", \r The vector is: " + rotvec);
            Assert.AreEqual(0, rotvec.Z, 1.5e-15, "Z should be 0, \r The vector is: " + rotvec);
        }
Example #2
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.
        }
Example #3
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
                    };
                }
            }
        }