Example #1
0
        public void TestEquatable()
        {
            var pol = new Polar(1.0f, 1.0f);

              Assert.IsTrue(pol.Equals(pol));
              Assert.IsFalse(pol.Equals(null));
        }
Example #2
0
        public void TestConversionToCartesian()
        {
            var pol = new Polar(5.0f, (float)Math.Acos(0.8));

              Assert.AreEqual(4.0f, pol.X);
              Assert.AreEqual(3.0f, pol.Y);
        }
Example #3
0
        public void TestOperatorDivide()
        {
            var pol = new Polar(1.0f, 0.0f);

              Assert.AreEqual(new Polar(0.5f, 0.0f), pol / 2.0f);
              Assert.AreEqual(new Polar(2.0f, 0.0f), 2.0f / pol);
              Assert.AreEqual(new Polar(1.0f, -Radian.PI), pol / (new Polar(1.0f, Radian.PI)));
              Assert.AreEqual(new Polar(0.5f, -Radian.PI), pol / (new Polar(2.0f, Radian.PI)));
        }
Example #4
0
        public void TestOperatorInequality()
        {
            var x = new Polar(1.0f, 0.0f);
              var y = new Polar(1.0f, 1.0f);

              Assert.IsFalse(x != x);
              Assert.IsFalse(x != (new Polar(1.0f, 0.0f)));
              Assert.IsTrue(x != y);
              Assert.IsTrue(x != Polar.Zero);
        }
Example #5
0
        public void TestConstruct()
        {
            Assert.AreEqual(0.0f, Polar.Zero.Radius);
              Assert.AreEqual((Radian)0.0f, Polar.Zero.Angle);

              var pol1 = new Polar(1.0f, 2.0f);
              var pol2 = new Polar(3.0f, new Radian(4.0f));

              Assert.AreEqual(1.0f, pol1.Radius);
              Assert.AreEqual((Radian)2.0f, pol1.Angle);
              Assert.AreEqual(3.0f, pol2.Radius);
              Assert.AreEqual(4.0f, (float)pol2.Angle);
        }
Example #6
0
        public void TestRegularized()
        {
            var pol = new Polar(1.0f, 0.0f);

              Assert.AreEqual(new Polar(1.0f, Radian.PI), (new Polar(-1.0f, 0.0f)).Regularized);
              Assert.AreEqual(new Polar(1.0f, Radian.PI), (pol * -1.0f).Regularized);
              Assert.AreEqual(new Polar(1.0f, Radian.PI), (-pol).Regularized);
              Assert.AreEqual(new Polar(1.0f, Radian.PI), (new Polar(1.0f, -Radian.PI)).Regularized);
        }
Example #7
0
 /// <summary>
 /// Converts to cartesian.
 /// </summary>
 /// <param name="radius">The radius.</param>
 /// <param name="angle">The angle.</param>
 /// <returns>Point.</returns>
 public Point ToCartesian(double radius, double angle)
 {
     return(Polar.ToCartesian(X, Y, radius, angle));
 }
 private Vector2 PolarToCartesian(Polar polar)
 {
     return(new Vector2(polar.radius * Mathf.Cos(polar.angle),
                        polar.radius * Mathf.Sin(polar.angle)));
 }
Example #9
0
        public void generateTree(Position center)
        {
            var tile       = new Tile(Color.Green, Color.Black, 0);
            var centerTile = new Tile(Color.Blue, Color.Black, 0);

            // Generate radii for the four angles 0, pi/2, pi and 3pi/2
            double[] angles = { 0, Math.PI / 2.0, Math.PI, (3.0 * Math.PI) / 2.0 };
            double[] radii  = new double[4];

            do
            {
                for (int i = 0; i < radii.Length; ++i)
                {
                    //radii[i] = rnd.NextDouble() * (maxRadius - minRadius) + minRadius;
                    radii[i] = rnd.NextDouble() * ((maxRadius + 0.5) - (maxRadius / 1.5)) + maxRadius / 1.5;
                }
                //} while (radii.Zip(radii.Skip(1), (x, y) => y - x).Min() < 0.3);
                //} while (radii.Zip(radii.Skip(1), (x, y) => Math.Abs(y - x)).Min() < 0.3);
            } while ((Math.Abs(radii[0] - radii[2]) < 0.2) || (Math.Abs(radii[1] - radii[3]) < 0.2));

            Console.WriteLine("\n---Generated radii:");
            for (int i = 0; i < radii.Length; ++i)
            {
                Console.WriteLine(radii[i]);
            }
            Console.WriteLine("---");

            // Check all
            for (int iy = -(int)maxRadius; iy <= (int)maxRadius; ++iy)
            {
                for (int ix = -(int)maxRadius; ix <= (int)maxRadius; ++ix)
                {
                    var p = Polar.FromVector(new Vector(ix, iy));

                    int ia = 0, ib = 0;
                    var found = false;

                    for (int i = 1; i < radii.Length; ++i)
                    {
                        if (p.Angle <= angles[i])
                        {
                            ia    = i - 1;
                            ib    = i;
                            found = true;
                            break;
                        }
                    }

                    if (!found)
                    {
                        ia = 3;
                        ib = 0;
                    }

                    var r = CommonMath.LMap(p.Angle, angles[ia], (ib == 0 ? 2.0 * Math.PI : angles[ib]), radii[ia],
                                            radii[ib]);

                    r = Math.Abs(r);

                    if (new Vector(2, 0) == new Vector(ix, iy))
                    {
                        Console.WriteLine(new Vector(ix, iy) + ":");
                        Console.WriteLine("Calculated radius: " + r + ", Radius of point: " + p.Radius + ", Angle of point: " + p.Angle);
                    }

                    if (new Vector(0, -2) == new Vector(ix, iy))
                    {
                        Console.WriteLine(new Vector(ix, iy) + ":");
                        Console.WriteLine("Calculated radius: " + r + ", Radius of point: " + p.Radius + ", Angle of point: " + p.Angle);
                    }

                    if (new Vector(-2, 0) == new Vector(ix, iy))
                    {
                        Console.WriteLine(new Vector(ix, iy) + ":");
                        Console.WriteLine("Calculated radius: " + r + ", Radius of point: " + p.Radius + ", Angle of point: " + p.Angle);
                    }

                    if (new Vector(0, 2) == new Vector(ix, iy))
                    {
                        Console.WriteLine(new Vector(ix, iy) + ":");
                        Console.WriteLine("Calculated radius: " + r + ", Radius of point: " + p.Radius + ", Angle of point: " + p.Angle);
                    }

                    if (p.Radius <= r)
                    {
                        var pos = Position.FromVector(new Vector(ix, iy) + Vector.FromPosition(center));

                        Screen.SetTile(pos, tile);
                    }
                }
            }

            Screen.SetTile(center, centerTile);
        }
Example #10
0
        /// <summary>
        /// 矫正
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public override bool Revise(ref EpochInformation info)
        {
            info.RemoveNoEphemeris();

            if (info.Count == 0)
            {
                return(false);
            }

            if (XYZ.IsZeroOrEmpty(info.SiteInfo.EstimatedXyz))
            {
                return(true);//此处让可以继续执行
            }

            List <SatelliteNumber> tobeDeleteSatsOfLowAnlge = new List <SatelliteNumber>();
            List <SatelliteNumber> tobeDeleteSatsOfUnhealth = new List <SatelliteNumber>();
            List <SatelliteNumber> tobeDeleteSatsOfNoEphs   = new List <SatelliteNumber>();

            foreach (var sat in info.EnabledSats)
            {
                if (!sat.HasEphemeris)
                {
                    tobeDeleteSatsOfNoEphs.Add(sat.Prn);
                    //      log.Error(sat.Prn + ", " + info.ReceiverTime + " , 没有星历!");

                    sat.Enabled = false;
                    continue;
                }

                //高度截止角
                Polar polar = sat.Polar;
                if (polar.Elevation < VertAngleCut)
                {
                    sat.Enabled = false;
                    tobeDeleteSatsOfLowAnlge.Add(sat.Prn);//是佛不用删除????2014.12.17
                }

                //是否健康
                //   if (!EphemerisService.IsHealth(key.Prn, info.CorrectedTime))
                if (!EphemerisService.IsAvailable(sat.Prn, info.ReceiverTime))
                {
                    sat.Enabled = false;
                    tobeDeleteSatsOfUnhealth.Add(sat.Prn);
                }
            }

            //debug
            if (tobeDeleteSatsOfLowAnlge.Count > 0 && tobeDeleteSatsOfLowAnlge.FindAll(m => !RemovedPrn.Contains(m)).Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append(info.Name + "," + info.ReceiverTime + ", 高度截止角低于 " + VertAngleCut + " 的卫星: ");
                sb.Append(String.Format(new EnumerableFormatProvider(), "{0}", tobeDeleteSatsOfLowAnlge));
                log.Debug(sb.ToString());
                RemovedPrn.AddRange(tobeDeleteSatsOfLowAnlge.FindAll(m => !RemovedPrn.Contains(m)));
            }
            info.Remove(tobeDeleteSatsOfLowAnlge, true, "删除高度截止角低于 " + VertAngleCut + " 的卫星");
            info.Remove(tobeDeleteSatsOfNoEphs, true, "删除没有星历的卫星");


            if (tobeDeleteSatsOfUnhealth.Count > 0)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append("不健康的卫星: ");
                sb.Append(String.Format(new EnumerableFormatProvider(), "{0}", tobeDeleteSatsOfUnhealth));
                log.Debug(sb.ToString());

                info.Remove(tobeDeleteSatsOfUnhealth, true, "不健康的卫星");
            }

            return(info.EnabledPrns.Count > 0);
        }
Example #11
0
        public Flatland.Turtle Move(double distance)
        {
            var newPosition = new Polar(angle, distance).ToCartesian().Offset(position);

            return(MoveTo(newPosition));
        }
Example #12
0
 /// <summary>
 /// 默认构造函数。
 /// </summary>
 public SatMovingDiffer(SatelliteNumber Prn, Polar first, Polar next)
 {
     this.Prn         = Prn;
     this.FirstPolar  = first;
     this.SecondPolar = next;
 }
Example #13
0
        //Test & Example to call setter commands, except robot's motion
        // CAUTION: some operation includes output
        // - Beep (outputs some sound)
        // - Motor ON/OFF
        // - Suction cup ON/OFF
        // - Gripper ON/OFF
        // - Digital Out 0 ON/OFF
        static async Task TestNoMotionCommands(IUArm uArm)
        {
            await uArm.BeepAsync(440, 50);

            Console.WriteLine("Detach All Motors");
            await uArm.DetachAllMotorAsync();

            await Task.Delay(500);

            Console.WriteLine("Attach All Motors");
            await uArm.AttachAllMotorAsync();

            await Task.Delay(500);

            Console.WriteLine("Detach All Motors");
            await uArm.DetachMotorAsync(Servos.Bottom);

            await uArm.DetachMotorAsync(Servos.Left);

            await uArm.DetachMotorAsync(Servos.Right);

            await Task.Delay(500);

            Console.WriteLine("Attach All Motors");
            await uArm.AttachMotorAsync(Servos.Bottom);

            await uArm.AttachMotorAsync(Servos.Left);

            await uArm.AttachMotorAsync(Servos.Right);

            await Task.Delay(500);

            // Pos -> Angles by IK -> Pos by FK (Math)
            var pos    = new Position(100, 100, 100);
            var angles = await uArm.GetIKAsync(pos);

            Console.WriteLine($"IK, src: X={pos.X}, Y={pos.Y}, Z={pos.Z}");
            Console.WriteLine($"IK, res: L={angles.Bottom}, B={angles.Left}, R={angles.Right}");

            pos = await uArm.GetFKAsync(angles);

            Console.WriteLine($"FK, src: L={angles.Bottom}, B={angles.Left}, R={angles.Right}");
            Console.WriteLine($"FK, res: X={pos.X}, Y={pos.Y}, Z={pos.Z}");

            // Can Reach or not
            pos = new Position(100, 100, 100);
            Console.WriteLine($"Can reach to (x,y,z)=({pos.X}, {pos.Y}, {pos.Z})? : {await uArm.CanReachAsync(pos)}");
            pos = new Position(300, 300, 100);
            Console.WriteLine($"Can reach to (x,y,z)=({pos.X}, {pos.Y}, {pos.Z})? : {await uArm.CanReachAsync(pos)}");

            var polar = new Polar(100, 45, 100);

            Console.WriteLine($"Can reach to (s,r,h)=({polar.Stretch}, {polar.Rotation}, {polar.Height})? : {await uArm.CanReachAsync(polar)}");
            polar = new Polar(400, 200, 100);
            Console.WriteLine($"Can reach to (s,r,h)=({polar.Stretch}, {polar.Rotation}, {polar.Height})? : {await uArm.CanReachAsync(polar)}");

            Console.WriteLine("Activate and deactivate the pump");
            await Task.Delay(1000);

            await uArm.SetPumpStateAsync(true);

            await Task.Delay(1000);

            await uArm.SetPumpStateAsync(false);

            Console.WriteLine("Activate and deactivate the gripper");
            await Task.Delay(1000);

            await uArm.SetGripperStateAsync(true);

            await Task.Delay(1000);

            await uArm.SetGripperStateAsync(false);

            // NO bluetooth operation, because when using this, serial connection will be shut down!
            //Console.WriteLine("Activate and deactivate the bluetooth");
            //await Task.Delay(1000);
            //await uArm.SetBluetoothStateAsync(true);
            //await Task.Delay(1000);
            //await uArm.SetBluetoothStateAsync(false);

            Console.WriteLine("Change digital Out 0 to high, and low");
            await Task.Delay(1000);

            await uArm.SetDigitalPinOutputAsync(0, true);

            await Task.Delay(1000);

            await uArm.SetDigitalPinOutputAsync(0, false);

            Console.WriteLine("Change ArmMode to Normal, Laser, Printing, Universal Holder, and then Normal again");
            await Task.Delay(500);

            await uArm.SetArmModeAsync(ArmModes.Normal);

            await Task.Delay(500);

            await uArm.SetArmModeAsync(ArmModes.Laser);

            await Task.Delay(500);

            await uArm.SetArmModeAsync(ArmModes.Printing);

            await Task.Delay(500);

            await uArm.SetArmModeAsync(ArmModes.UniversalHolder);

            await Task.Delay(500);

            await uArm.SetArmModeAsync(ArmModes.Normal);

            Console.WriteLine("Set Current Position to the reference position");
            try
            {
                await uArm.UpdateReferencePoint();
            }
            catch (UArmException ex)
            {
                Console.WriteLine("Expected error, message: " + ex.Message);
            }

            Console.WriteLine("Set Height zero Point");
            await uArm.UpdateHeightZeroPoint();

            Console.WriteLine("Set End Effector Height 100mm, and 0mm");
            await uArm.SetEndEffectorHeight(100);

            await uArm.SetEndEffectorHeight(0);
        }
Example #14
0
        public void TestOperatorMultiply()
        {
            var pol = new Polar(1.0f, 0.0f);

              Assert.AreEqual(new Polar(2.0f, 0.0f), pol * 2.0f);
              Assert.AreEqual(new Polar(2.0f, 0.0f), 2.0f * pol);
              Assert.AreEqual(new Polar(1.0f, Radian.PI), pol * (new Polar(1.0f, Radian.PI)));
              Assert.AreEqual(new Polar(2.0f, Radian.PI), pol * (new Polar(2.0f, Radian.PI)));
        }
Example #15
0
 private Turtle DrawLineSegment(Turtle turtle, Cartesian p1, Polar p2)
 {
     return(turtle.MoveTo(p1).Line(p2));
 }
Example #16
0
        /// <summary>
        /// 指定时段内,可以看见的卫星。
        /// </summary>
        /// <returns></returns>
        public List <VisibilityOfSat> GetPeriodSatAppearTimes()
        {
            this.LonLats.Clear();
            List <VisibilityOfSat> sats  = new List <VisibilityOfSat>();
            List <StationSatInfo>  infos = new List <StationSatInfo>();
            List <SatelliteNumber> prns  = new List <SatelliteNumber>();

            //  EphemerisService.EphemerisDataSource.GetEphemerisInfos(
            foreach (SatelliteNumber rec in EphemerisService.Prns)//卫星一颗一颗的算
            {
                if (prns.Contains(rec))
                {
                    continue;
                }
                prns.Add(rec);

                VisibilityOfSat satA = new VisibilityOfSat()
                {
                    PRN = rec, VisibleTimes = new List <BufferedTimePeriod>()
                };
                sats.Add(satA);
                Polar lastP = null;

                DateTime f = DateTime.MinValue;
                for (int i = 0; i < Count; i++)
                {
                    DateTime            time  = From + TimeSpan.FromMinutes(i * SpanMinutes);
                    Time                g     = new Time(time);
                    Geo.Coordinates.XYZ xyz   = EphemerisService.Get(rec, g).XYZ;
                    GeoCoord            coord = CoordTransformer.XyzToGeoCoord(xyz);
                    Polar               p     = CoordTransformer.XyzToGeoPolar(xyz, StationPos);

                    if (lastP == null)
                    {
                        lastP = p; continue;
                    }

                    if (p.Elevation >= EleAngle)
                    {
                        if (f.Equals(DateTime.MinValue) || lastP.Elevation < EleAngle)
                        {
                            f     = time;
                            lastP = p;
                            continue;
                        }
                    }
                    if (p.Elevation < EleAngle || i == Count - 1)                       //当前小于指定高度角
                    {
                        if (!f.Equals(DateTime.MinValue) && lastP.Elevation > EleAngle) //且上一个时刻是大于的,则终端出现了。
                        {
                            BufferedTimePeriod s = new BufferedTimePeriod(f, time);
                            satA.VisibleTimes.Add(s);
                            this.LonLats.Add(new Vector(coord.Lon, coord.Lat)
                            {
                                Tag = rec.PRN.ToString()
                            });
                        }
                    }
                    lastP = p;
                }
            }
            sats.Sort();

            return(sats);
        }
Example #17
0
    protected void Transfer(Vector3 endPoint, Vector3 endFwd, System.Action onTransferred = null)
    {
        _transfer = StartCoroutine(_Transfer());
        IEnumerator _Transfer()
        {
            Vector3 startFwd   = transform.forward;
            Vector3 startPoint = transform.position;

            endPoint += endFwd * (Vector3.Distance(startPoint, endPoint) / 2);

            // Get circle
            Vector3 startRight = transform.right;
            Vector3 endRight   = Vector3.Cross(endFwd, Vector3.up);
            Vector2 ctr2       = Vector2.zero;
            Vector3 p0         = startPoint;
            Vector3 p1         = startPoint + (startRight * 100);
            Vector3 p2         = endPoint;
            Vector3 p3         = endPoint - (endRight * 100);

            // Try every f*****g permutation
            if (!LineIntersection(XZ(p0), XZ(p1), XZ(p2), XZ(p3), ref ctr2))
            {
                p3 = endPoint + (endRight * 100);
                if (!LineIntersection(XZ(p0), XZ(p1), XZ(p2), XZ(p3), ref ctr2))
                {
                    p1 = startPoint - (startRight * 100);
                    if (!LineIntersection(XZ(p0), XZ(p1), XZ(p2), XZ(p3), ref ctr2))
                    {
                        p3 = endPoint - (endRight * 100);
                        LineIntersection(XZ(p0), XZ(p1), XZ(p2), XZ(p3), ref ctr2);
                    }
                }
            }
            Vector3 centre = new Vector3(ctr2.x, 0, ctr2.y);
            float   radius = Vector3.Distance(startPoint, centre);

            float dTheta     = Vector3.SignedAngle(startFwd, endFwd, -Vector3.up) * Mathf.Deg2Rad;
            float arcLength  = Mathf.Abs(dTheta * radius);
            float startTheta = Mathf.Repeat(Polar.ToPolar(transform.position, centre), Mathf.PI * 2);
            float endTheta   = startTheta + dTheta;

            float time = arcLength / Speed;

            // Debug.DrawLine(p0, p1, Color.magenta, 10f);
            // Debug.DrawLine(p2, p3, Color.magenta, 10f);
            // Debug.DrawRay(startPoint, startFwd*100, Color.yellow, 10f);
            // Debug.DrawRay(endPoint, endFwd*100, Color.yellow, 10f);
            // Debug.DrawLine(startPoint, centre, Color.green, 10f);
            _tp0    = p0;
            _tp1    = p1;
            _tp2    = p2;
            _tp3    = p3;
            _tStart = startPoint;
            _tsFwd  = startFwd;
            _tEnd   = endPoint;
            _teFwd  = endFwd;
            _tCtr   = centre;
            _tRad   = radius;

            float t = 0;

            while (t < time)
            {
                float p     = t / time;
                float theta = Mathf.Lerp(startTheta, endTheta, p);
                theta = Mathf.Repeat(theta, Mathf.PI * 2);
                Vector3 circlePos = Polar.FromPolar(theta, radius, centre);
                transform.position = Vector3.Lerp(circlePos, Vector3.Lerp(startPoint, endPoint, p), Mathf.Sqrt(p));
                transform.rotation = Quaternion.Slerp(Quaternion.LookRotation(startFwd, Vector3.up), Quaternion.LookRotation(endFwd, Vector3.up), p);
                t += Time.deltaTime;
                yield return(null);
            }

            transform.position = endPoint;
            transform.forward  = endFwd;
            onTransferred?.Invoke();
            _transfer = null;
        }
    }
Example #18
0
        /// <summary>
        /// 数据刚刚进入,立即执行,最优先的执行,初探
        /// </summary>
        /// <param name="current"></param>
        public override void RawRevise(RinexEpochObservation current)
        {
            //时段过滤
            if (Option.IsEnableTimePeriod)
            {
                if (!Option.TimePeriod.Contains(current.ReceiverTime))
                {
                    current.Clear(); return;
                }
            }

            //采样率时间赋值
            if (this.CurrentIndex == 0 || this.CurrentIndex == -1)
            {
                this.CurrentIndex = 1;
                InitSeconds       = current.ReceiverTime.DateTime.TimeOfDay.TotalSeconds;
                if (Option.IsEnableInterval && Option.Interval > 1 && InitSeconds % 5 != 0) // 若非0, 5秒整数倍的采样间隔,则强制采用10秒整数倍间隔
                {
                    InitSeconds = 0;
                }
            }

            //采样间隔过滤
            if (Option.IsEnableInterval)
            {
                //首先考虑采样率大于1s
                var diff = Math.Round(current.ReceiverTime.DateTime.TimeOfDay.TotalSeconds - InitSeconds) % Option.Interval;
                if (diff > 0.5 && Option.Interval > 1)//相差0.5s,认为是同一个历元
                {
                    current.Clear();
                    return;
                }

                //采样率太小,直接过滤
                if (current.ReceiverTime - PrevOkEpoch < Option.Interval)
                {
                    current.Clear();
                    return;
                }

                //10s 以上的整数必须为10倍的整数秒,如 30s采样率,只能出现 00 和 30 秒
                if (Option.Interval >= 10 && Option.Interval <= 30 && current.ReceiverTime.Seconds % Option.Interval > 1)
                {
                    current.Clear();
                    return;
                }
            }


            //移除其它系统
            if (Option.IsEnableSatelliteTypes)
            {
                current.RemoveOther(Option.SatelliteTypes);
            }


            //观测类型过滤凭借第一字母判断,此处过滤可以加快速度,避免多余计算
            if (Option.IsEnableObsTypes)
            {
                current.RemoveOthers(Option.ObsTypes);
            }

            //删除观测频率
            if (Option.IsEnableRemoveIndicatedFrequence)
            {
                current.RemoveFrequences(Option.FrequenceNumToBeRemoved);
                // log.Info("除频率:" + Geo.Utils.StringUtil.ToString(Option.FrequenceNumToBeRemoved));
            }

            //移除不能组成电离层组合的卫星
            if (Option.IsRemoveIonoFreeUnavaliable)
            {
                List <RinexSatObsData> list = new List <RinexSatObsData>();
                foreach (var sat in current)
                {
                    if (!sat.IsIonoFreeCombinationAvaliable)
                    {
                        list.Add(sat);
                    }
                }
                foreach (var item in list)
                {
                    current.Remove(item.Prn);
                }
            }

            //移除卫星中对于双频无电离层组合多余的观测值
            if (Option.IsRemoveRedundantObsForIonoFree)
            {
                foreach (var sat in current)
                {
                    sat.RemoveRedundantObsForIonoFree();
                }
            }


            //观测码数量不足的移除
            if (ObsCodesToBeRemove != null && ObsCodesToBeRemove.Count > 0)
            {
                foreach (var sat in current)
                {
                    if (!ObsCodesToBeRemove.ContainsKey(sat.Prn.SatelliteType))
                    {
                        continue;
                    }

                    var codes = this.ObsCodesToBeRemove[sat.Prn.SatelliteType];

                    foreach (var item in codes)
                    {
                        sat.Remove(item);
                    }
                }
            }

            //移除指定卫星
            if (Option.IsEnableRemoveSats && Option.SatsToBeRemoved != null && Option.SatsToBeRemoved.Count > 0)
            {
                current.Remove(Option.SatsToBeRemoved);
            }

            //卫星高度角过滤
            if (Option.SatCutOffAngle.Enabled && !XYZ.IsZeroOrEmpty(OldHeader.ApproxXyz))
            {
                //如果星历范围不包括,则不做更改
                if (EphemerisService.TimePeriod.Contains(current.ReceiverTime))
                {
                    List <RinexSatObsData> list = new List <RinexSatObsData>();
                    foreach (var item in current)
                    {
                        var   eph   = EphemerisService.Get(item.Prn, current.ReceiverTime);
                        Polar polar = null;
                        if (eph != null)
                        {
                            polar = CoordTransformer.XyzToGeoPolar(eph.XYZ, OldHeader.ApproxXyz);
                        }
                        //移除了没有星历的卫星
                        if (polar == null || polar.Elevation < Option.SatCutOffAngle.Value)
                        {
                            list.Add(item);
                        }
                    }
                    foreach (var item in list)
                    {
                        current.Remove(item.Prn);
                    }
                }
            }
            //删除指定数据为空的卫星
            if (Option.IsDeleteVacantSat)
            {
                List <SatelliteNumber> tobeDeletes = new List <SatelliteNumber>();
                foreach (var sat in current)
                {
                    foreach (var item in Option.NotVacantCodeList)
                    {
                        if (sat.TryGetValue(item) == 0)
                        {
                            tobeDeletes.Add(sat.Prn);
                        }
                    }
                }
                current.Remove(tobeDeletes);
            }

            base.RawRevise(current);

            //小时段过滤
            if (Option.IsEnableMinEpochCount)
            {
                SmallObsPeriodRemover.Revise(ref current);
            }
        }
Example #19
0
 public Flatland.Turtle Line(Polar p)
 {
     return(Turn(p.A).Line(p.R));
 }
    public static void Run()
    {
        ReactAutoA testAuto = new ReactAutoA();

        bool   aBool     = true;
        string aSymb     = "my_symbol";
        long   anInt     = 42;
        double aFloat    = 3.14159;
        string aString   = "Imagine there's no heaven...";
        long   aTimeSpan = 60000;
        var    aRect     = (color : "blue", width : 4.16, height : 0.81, bottomLeft : (x : 25, y : 9));
        // string aRect = "(color: blue, width: 4.16, height: 0.81, bottom_left: point(x: 25, y: 9))";
        var aDateRec = (day : 15, year : 2007, month : 3);

        // string aDateRec = "(day: 15, year: 2007, month: 3)";
        (int, int, int)aDate = (5, 2, 2018);

        var aPoint = (x : 12, y : 7);
        // string aPoint = "point(x: 12, y: 7)";

        Polar    polar          = new Polar(ro: 6.28318, theta: 1.73205);
        AnyPoint anAnyPoint     = polar;
        string   anAnyPoint_str = "polar(ro: 6.28318, theta: 1.73205)";

        var aTuple = (2.71828, "It's easy if you try...", new long[] { 1, 1, 2, 6, 24 });

        bool[]   aBoolSeq   = new bool[] { true, false, false, true };
        long[]   anIntSeq   = new long[] { 100, 101, 102, 103, 104, 105 };
        double[] aFloatSeq  = new double[] { -2.0, -1.0, 0.0, 1.0, 2.0, 3.0 };
        string[] aPointSeq  = new string[] { "point(x: 0, y: 0)", "point(x: 1, y: 1)", "point(x: 2, y: 4)" };
        string   _aPointSeq = "(point(x: 0, y: 0), point(x: 1, y: 1), point(x: 2, y: 4))";

        long[] aTimeSpanSeq = new long[] { 60, 3600, 86420 };
        // string anIntToSymbMap = "[0 -> zero, 1 -> one, 2 -> two, 3 -> three]";
        string anIntToSymbMap = "[1 -> one, 2 -> two, 0 -> zero, 3 -> three]";

        testAuto.ABoolInput     = aBool;
        testAuto.ASymbInput     = aSymb;
        testAuto.AnIntInput     = anInt;
        testAuto.AFloatInput    = aFloat;
        testAuto.AStringInput   = aString;
        testAuto.ATimeSpanInput = aTimeSpan;
        testAuto.ARectInput     = aRect;
        // testAuto.SetInput(ReactAutoA.Input.A_RECT_INPUT, aRect);
        testAuto.ADateRecInput = aDateRec;
        // testAuto.SetInput(ReactAutoA.Input.A_DATE_REC_INPUT, aDateRec);
        testAuto.ADateInput = aDate;
        // testAuto.SetInput(ReactAutoA.Input.A_DATE_INPUT, _aDate);
        testAuto.APointInput = aPoint;
        // testAuto.SetInput(ReactAutoA.Input.A_POINT_INPUT, aPoint);
        testAuto.AnAnyPointInput = anAnyPoint_str;
        // testAuto.SetInput(ReactAutoA.Input.AN_ANY_POINT_INPUT, anAnyPoint);
        testAuto.ATupleInput = aTuple;
        // testAuto.SetInput(ReactAutoA.Input.A_TUPLE_INPUT, _aTuple);
        testAuto.ABoolSeqInput  = aBoolSeq;
        testAuto.AnIntSeqInput  = anIntSeq;
        testAuto.AFloatSeqInput = aFloatSeq;
        // testAuto.APointSeqInput = aPointSeq;
        testAuto.SetInput(ReactAutoA.Input.A_POINT_SEQ_INPUT, _aPointSeq);
        testAuto.ATimeSpanSeqInput = aTimeSpanSeq;
        // testAuto.AnIntToSymbMapInput = anIntToSymbMap;
        testAuto.SetInput(ReactAutoA.Input.AN_INT_TO_SYMB_MAP_INPUT, anIntToSymbMap);

        testAuto.Apply();

        if (testAuto.ABoolOutput != aBool)
        {
            Console.WriteLine("ERROR: ABoolOutput = {0}, ABool = {1}", testAuto.ABoolOutput, aBool);
            return;
        }

        if (testAuto.ASymbOutput != aSymb)
        {
            Console.WriteLine("ERROR: ASymbOutput = {0}, ASymb = {1}", testAuto.ASymbOutput, aSymb);
            return;
        }

        if (testAuto.AnIntOutput != anInt)
        {
            Console.WriteLine("ERROR: AnIntOutput = {0}, AnInt = {1}", testAuto.AnIntOutput, anInt);
            return;
        }

        if (testAuto.AFloatOutput != aFloat)
        {
            Console.WriteLine("ERROR: AFloatOutput = {0}, AFloat = {1}", testAuto.AFloatOutput, aFloat);
            return;
        }

        if (testAuto.AStringOutput != aString)
        {
            Console.WriteLine("ERROR: AStringOutput = {0}, AString = {1}", testAuto.AStringOutput, aString);
            return;
        }

        if (testAuto.ATimeSpanOutput != aTimeSpan)
        {
            Console.WriteLine("ERROR: ATimeSpanOutput = {0}, ATimeSpan = {1}", testAuto.ATimeSpanOutput, aTimeSpan);
            return;
        }

        var outRect = testAuto.ARectOutput;

        if (
            outRect.color != aRect.color ||
            outRect.width != aRect.width ||
            outRect.height != aRect.height ||
            outRect.bottomLeft.x != aRect.bottomLeft.x ||
            outRect.bottomLeft.y != aRect.bottomLeft.y
            )
        {
            Console.WriteLine("ERROR: ARectOutput = {0}, aRect = {1}", outRect, aRect);
            return;
        }

        var outDateRec = testAuto.ADateRecOutput;

        if (outDateRec != aDateRec)
        {
            Console.WriteLine("ERROR: aDateRecOutput = {0}, aDateRec = {1}", outDateRec, aDateRec);
            return;
        }

        if (testAuto.ADateOutput.Item1 != aDate.Item1)
        {
            Console.WriteLine("ERROR: ADateOutput.Item1 = {0}, ADate.Item1 = {1}", testAuto.ADateOutput.Item1, aDate.Item1);
            return;
        }

        if (testAuto.ADateOutput.Item2 != aDate.Item2)
        {
            Console.WriteLine("ERROR: ADateOutput.Item2 = {0}, ADate.Item2 = {1}", testAuto.ADateOutput.Item2, aDate.Item2);
            return;
        }

        if (testAuto.ADateOutput.Item3 != aDate.Item3)
        {
            Console.WriteLine("ERROR: ADateOutput.Item3 = {0}, ADate.Item3 = {1}", testAuto.ADateOutput.Item3, aDate.Item3);
            return;
        }

        var outPoint = testAuto.APointOutput;

        if (outPoint.x != aPoint.x || outPoint.y != aPoint.y)
        {
            Console.WriteLine("ERROR: APointOutput = {0}, APoint = {1}", outPoint, aPoint);
            return;
        }

        if (testAuto.AnAnyPointOutput.ToString() != anAnyPoint.ToString())
        {
            Console.WriteLine("ERROR: AnAnyPointOutput = {0}, AnAnyPoint = {1}", testAuto.AnAnyPointOutput, anAnyPoint);
            return;
        }

        if (testAuto.ATupleOutput.Item1 != aTuple.Item1)
        {
            Console.WriteLine("ERROR: ATupleOutput.Item1 = {0}, ATuple.Item1 = {1}", testAuto.ATupleOutput.Item1, aTuple.Item1);
            return;
        }

        if (testAuto.ATupleOutput.Item2 != aTuple.Item2)
        {
            Console.WriteLine("ERROR: ATupleOutput.Item2 = {0}, ATuple.Item2 = {1}", testAuto.ATupleOutput.Item2, aTuple.Item2);
            return;
        }

        if (!Eq(testAuto.ATupleOutput.Item3, aTuple.Item3))
        {
            Console.WriteLine("ERROR: ATupleOutput.Item3 = {0}, ATuple.Item3 = {1}", testAuto.ATupleOutput.Item3, aTuple.Item3);
            return;
        }

        if (!Eq(testAuto.ABoolSeqOutput, aBoolSeq))
        {
            Console.WriteLine("ERROR: ABoolSeqOutput = {0}, ABoolSeq = {1}", testAuto.ABoolSeqOutput, aBoolSeq);
            return;
        }

        if (!Eq(testAuto.AnIntSeqOutput, anIntSeq))
        {
            Console.WriteLine("ERROR: AnIntSeqOutput = {0}, AnIntSeq = {1}", testAuto.AnIntSeqOutput, anIntSeq);
            return;
        }

        if (!Eq(testAuto.AFloatSeqOutput, aFloatSeq))
        {
            Console.WriteLine("ERROR: AFloatSeqOutput = {0}, AFloatSeq = {1}", testAuto.AFloatSeqOutput, aFloatSeq);
            return;
        }


        var outPointSeq = testAuto.APointSeqOutput;

        string[] strs = new string[outPointSeq.Length];
        for (int i = 0; i < strs.Length; i++)
        {
            strs[i] = string.Format("point(x: {0}, y: {1})", outPointSeq[i].x, outPointSeq[i].y);
        }
        if (!EqStrV(strs, aPointSeq))
        {
            Console.WriteLine("ERROR: APointSeqOutput = {0}, APointSeq = {1}", strs, _aPointSeq);
            return;
        }

        if (!Eq(testAuto.ATimeSpanSeqOutput, aTimeSpanSeq))
        {
            Console.WriteLine("ERROR: ATimeSpanSeqOutput = {0}, ATimeSpanSeq = {1}", testAuto.ATimeSpanSeqOutput, aTimeSpanSeq);
            return;
        }

        // (long, string)[] AnIntToSymbMapOutput;
        string str = "[";

        foreach (var entry in testAuto.AnIntToSymbMapOutput)
        {
            if (str != "[")
            {
                str += ", ";
            }
            str += string.Format("{0} -> {1}", entry.Item1, entry.Item2);
        }
        str += "]";
        if (str != anIntToSymbMap)
        {
            Console.WriteLine("ERROR: AnIntToSymbMapOutput = {0}, anIntToSymbMap = {1}", str, anIntToSymbMap);
            return;
        }

        Console.WriteLine("Reactive automata tests passed!");
    }
Example #21
0
 public Flatland.Turtle Move(Polar p)
 {
     return(Turn(p.A).Move(p.R));
 }
Example #22
0
        public static string ToString2(this Polar p)
        {
            string s = "(Angle " + p.Angle + ";Distance " + p.Distance + ")";

            return(s);
        }
 public override int GetHashCode()
 {
     int hash = ((Radius.GetHashCode() << 5) + Radius.GetHashCode()) ^ Polar.GetHashCode();
     hash = ((hash << 5) + hash) ^ Elevation.GetHashCode();
     return hash;
 }
Example #24
0
 void Start()
 {
     mPolar            = new Polar(transform.position - Target.transform.position);
     mRelativePosition = transform.position - Target.transform.position;
 }
Example #25
0
        private void PSCalc_Click(object sender, EventArgs e)
        {
            double.TryParse(txt_Ua.Text, out double Ua);
            double.TryParse(txt_UaPhi.Text, out double PhiUa);
            double.TryParse(txt_Ub.Text, out double Ub);
            double.TryParse(txt_UbPhi.Text, out double PhiUb);
            double.TryParse(txt_Uc.Text, out double Uc);
            double.TryParse(txt_UcPhi.Text, out double PhiUc);

            double.TryParse(txt_Ia.Text, out double Ia);
            double.TryParse(txt_IaPhi.Text, out double PhiIa);
            double.TryParse(txt_Ib.Text, out double Ib);
            double.TryParse(txt_IbPhi.Text, out double PhiIb);
            double.TryParse(txt_Ic.Text, out double Ic);
            double.TryParse(txt_IcPhi.Text, out double PhiIc);

            string format = "F3";

            PhaseSequence sequence = new PhaseSequence();

            {
                Polar vUa = new Polar(Ua, PhiUa);
                Polar vUb = new Polar(Ub, PhiUb);
                Polar vUc = new Polar(Uc, PhiUc);

                PSData vPositiveU = sequence.CalcPositive(vUa, vUb, vUc);

                txt_UPositive.Text    = vPositiveU.Amplitude.ToString(format);
                txt_PhiUPositive.Text = vPositiveU.Phase.ToString(format);

                PSData vNegativeU = sequence.CalcNegative(vUa, vUb, vUc);

                txt_UNegative.Text    = vNegativeU.Amplitude.ToString(format);
                txt_PhiUNegative.Text = vNegativeU.Phase.ToString(format);

                PSData vZeroU = sequence.CalcZero(vUa, vUb, vUc);

                txt_UZero.Text    = vZeroU.Amplitude.ToString(format);
                txt_PhiUZero.Text = vZeroU.Phase.ToString(format);
            }

            {
                Polar vIa = new Polar(Ia, PhiIa);
                Polar vIb = new Polar(Ib, PhiIb);
                Polar vIc = new Polar(Ic, PhiIc);

                PSData vPositiveI = sequence.CalcPositive(vIa, vIb, vIc);

                txt_IPositive.Text    = vPositiveI.Amplitude.ToString(format);
                txt_PhiIPositive.Text = vPositiveI.Phase.ToString(format);

                PSData vNegativeI = sequence.CalcNegative(vIa, vIb, vIc);

                txt_INegative.Text    = vNegativeI.Amplitude.ToString(format);
                txt_PhiINegative.Text = vNegativeI.Phase.ToString(format);

                PSData vZeroI = sequence.CalcZero(vIa, vIb, vIc);

                txt_IZero.Text    = vZeroI.Amplitude.ToString(format);
                txt_PhiIZero.Text = vZeroI.Phase.ToString(format);
            }
        }
Example #26
0
    public void Draw(double angle)
    {
        var pt = new Polar(angle, ORB_SHELL).ToCartesian();

        wireframe.Circle(pt, ORB_SIZE);
    }
 void Start()
 {
     mPolar    = new Polar(transform.position - Target.transform.position);
     mPosition = transform.position - Target.transform.position;
     mRB       = Target.GetComponent <Rigidbody> ();
 }
Example #28
0
 private void Draw(Cartesian p1, Polar p2)
 {
     endcapPt1.Circle(p1, ENDCAP_RADIUS);
     DrawArrowHead(DrawLineSegment(lineSegment, p1, p2));
 }
Example #29
0
        public PolarChart(ChartView BaseChart)
        {
            this.BaseChart = BaseChart;
            polar1         = new Polar();
            polar2         = new Polar();
            var            = new Variables.Variables();

            for (int i = 0; i < var.GetValorPolar1.Length / 2; i++)
            {
                polar1.Add(var.GetValorPolar1[i, 0], var.GetValorPolar1[i, 1]);
            }
            for (int i = 0; i < var.GetValorPolar2.Length / 2; i++)
            {
                polar2.Add(var.GetValorPolar2[i, 0], var.GetValorPolar2[i, 1]);
            }

            polar1.Color              = var.GetPaletteBasic[0];
            polar2.Color              = var.GetPaletteBasic[1];
            polar1.Circled            = true;
            polar2.Circled            = true;
            polar1.CloseCircle        = true;
            polar2.CloseCircle        = true;
            polar1.Pen.Color          = Color.White;
            polar2.Pen.Color          = Color.White;
            polar1.CircleLabels       = true;
            polar1.CircleLabelsInside = false;
            polar2.CircleLabels       = true;
            polar2.CircleLabelsInside = false;

            BaseChart.Chart.Series.Add(polar1);
            BaseChart.Chart.Series.Add(polar2);

            BaseChart.Chart.Title.Text        = "Polar";
            BaseChart.Chart.Axes.Left.Visible = true;
            BaseChart.Chart.Axes.Left.MinorTicks.Transparency   = 100;
            BaseChart.Chart.Axes.Bottom.MinorTicks.Transparency = 100;
            BaseChart.Chart.Axes.Left.SetMinMax(BaseChart.Chart.Axes.Left.MinYValue - 100, BaseChart.Chart.Axes.Left.MaxYValue + 100);
            BaseChart.Chart.Axes.Bottom.SetMinMax(BaseChart.Chart.Axes.Bottom.MinYValue - 100, BaseChart.Chart.Axes.Bottom.MaxXValue + 100);

            BaseChart.Chart.Axes.Bottom.Automatic          = true;
            BaseChart.Chart.Axes.Left.Labels.ValueFormat   = "0";
            BaseChart.Chart.Axes.Bottom.Labels.ValueFormat = "0";
            BaseChart.Chart.Axes.Bottom.Increment          = 1;
            BaseChart.Chart.Axes.Left.Increment            = 100;
            BaseChart.Chart.Axes.Left.Visible           = true;
            BaseChart.Chart.Axes.Left.Title             = null;
            BaseChart.Chart.Axes.Bottom.Title           = null;
            BaseChart.Chart.Axes.Left.AxisPen.Visible   = false;
            BaseChart.Chart.Axes.Left.Ticks.Visible     = false;
            BaseChart.Chart.Axes.Left.Grid.Visible      = true;
            BaseChart.Chart.Legend.LegendStyle          = LegendStyles.Series;
            BaseChart.Chart.Axes.Bottom.Grid.Visible    = false;
            BaseChart.Chart.Panel.MarginLeft            = 5;
            BaseChart.Chart.Axes.Bottom.AxisPen.Visible = true;
            BaseChart.Chart.Axes.Bottom.Visible         = true;
            BaseChart.Chart.Axes.Left.Increment         = 100;

            polar1.AngleIncrement         = 30;
            polar2.AngleIncrement         = 30;
            polar1.CircleLabelsFont.Size += 2;
            polar2.CircleLabelsFont.Size += 2;
            polar1.RadiusIncrement        = 300;
            polar2.RadiusIncrement        = 300;
        }
Example #30
0
 public Polar(Polar p) : this(p.r, p.theta)
 {
 }