Exemplo n.º 1
0
        public void Rotate_Matrix()
        {
            var coor       = new HealCoor(-90, 90);
            var normalCalm = Matrixes.Rotate(coor);

            //todo why angle with opposite sign?
            var rotation = Matrix3D.RotationAroundYAxis(new Angle(-coor.Phi, AngleUnit.Radians))
                           * Matrix3D.RotationAroundZAxis(new Angle(coor.Lambda.Value, AngleUnit.Radians));
            var normalCalmByMatrix = new UnitVector3D(Matrixes.RotationVector * rotation);

            Assert.AreEqual(normalCalm.X, normalCalmByMatrix.X, .00000001);
            Assert.AreEqual(normalCalm.Y, normalCalmByMatrix.Y, .00000001);
            Assert.AreEqual(normalCalm.Z, normalCalmByMatrix.Z, .00000001);
        }
Exemplo n.º 2
0
        /// <summary>
        /// maybe better reuse code from 5.3 Pixel Boundaries
        /// https://www.researchgate.net/publication/1801816_HEALPix_A_Framework_for_High-Resolution_Discretization_and_Fast_Analysis_of_Data_Distributed_on_the_Sphere
        /// </summary>
        public Ray3D MeanBoundary(HealCoor basin, Direction to)
        {
            var deltaX            = 360d / (basin.PixelsCountInRing * 2);
            var deltaXsign        = GetHor(to) == (int)NeighborHor.East ? 1 : -1;
            var sameRingBoundaryX = basin.X + deltaXsign * deltaX;

            var    toBasin  = _healpixManager.GetCenter <HealCoor>(Get(to, basin));
            var    toBasinX = toBasin.X;
            double?toBasinY;

            if (basin.Ring == 1 && GetVert(to) == NeighborVert.North)
            {
                toBasinY = 90;
            }
            else if (basin.Ring == _healpixManager.RingsCount && GetVert(to) == NeighborVert.South)
            {
                toBasinY = -90;
            }
            else
            {
                var boundaryRing   = basin.Ring + (GetVert(to) == NeighborVert.North ? -1 : 1);
                var boundaryDeltaX = 360d / (_healpixManager.PixelsCountInRing(boundaryRing) * 2);
                if (toBasin.Ring == basin.Ring)
                {
                    var toBasinOppositeHor = _healpixManager.GetCenter <HealCoor>(Get(GetOppositeHor(to), basin));
                    toBasinY = toBasinOppositeHor.Y;
                    toBasinX = toBasinOppositeHor.X + deltaXsign * boundaryDeltaX;
                }
                else
                {
                    toBasinY = toBasin.Y;
                    toBasinX = toBasinX - deltaXsign * boundaryDeltaX;
                }
            }

            var bisector = Matrixes.Rotate(new HealCoor(toBasinX, toBasinY.Value))
                           + Matrixes.Rotate(new HealCoor(sameRingBoundaryX, basin.Y));

            return(new Ray3D(Basin3.O3, bisector));
        }