コード例 #1
0
ファイル: Chart.cs プロジェクト: matthew-rimmer/DataFlow
        private void DrawUncertainties()
        {
            // Selects the current uncertainty type and draws it for each
            // Each type does it's respective drawing for each value in the ObservableCollection
            switch (CurrentUncertainty)
            {
            case Uncertainties.UncertaintyType.Indiv:
                // Draws the uncertainty for all the coordinates
                for (int i = 0; i < coordinates.Count; i++)
                {
                    IndivUncValues currentUncValues = new IndivUncValues(coordinates[i].XPlus, coordinates[i].XMinus, coordinates[i].YPlus, coordinates[i].YMinus);
                    Uncertainty    Unc = new Uncertainty(coordinates[i], currentUncValues, currentCanvas, GetBounds());
                }
                break;

            case Uncertainties.UncertaintyType.SingleAbs:
                // Draws the uncertainty for all the coordinates
                for (int i = 0; i < coordinates.Count; i++)
                {
                    Uncertainty Unc = new Uncertainty(coordinates[i], SingleUncXValue, SingleUncYValue, false, currentCanvas, GetBounds());
                }
                break;

            case Uncertainties.UncertaintyType.SinglePerc:
                // Draws the uncertainty for all the coordinates
                for (int i = 0; i < coordinates.Count; i++)
                {
                    Uncertainty Unc = new Uncertainty(coordinates[i], SingleUncXValue, SingleUncYValue, true, currentCanvas, GetBounds());
                }
                break;
            }
        }
コード例 #2
0
        public void TestUncertaintyFromEvenValues()
        {
            var u = new Uncertainty(4.5, 1.2);

            Assert.AreEqual(1.2, u.LowerUncertainty);
            Assert.AreEqual(1.2, u.UpperUncertainty);
            Assert.IsFalse(u.IsRelative);
        }
コード例 #3
0
        public void TestUncertaintyHashCode()
        {
            var u1 = new Uncertainty(0.8, 0.1, 0.2);
            var u2 = new Uncertainty(0.8, 0.2, 0.1);

            Assert.AreNotEqual(u1.GetHashCode(), u2.GetHashCode());
            Assert.AreEqual(u1.GetHashCode(), u1.Clone().GetHashCode());
        }
コード例 #4
0
        public void TestUncertaintyMax()
        {
            var u1 = new Uncertainty(2, 1, 0.5);
            var u2 = new Uncertainty(3, 0.5, 1);
            var u3 = u1.Max(u2);

            Assert.AreEqual(u2, u3);
        }
コード例 #5
0
ファイル: StepObject.cs プロジェクト: seanays/CAF
 public override void SetID(IDGenerator idGenerator)
 {
     ID = idGenerator.GetID();
     Uncertainty.SetID(idGenerator);
     LengthUnit.SetID(idGenerator);
     PlaneAngleUnit.SetID(idGenerator);
     SolidAngleUnit.SetID(idGenerator);
 }
コード例 #6
0
        public void TestUncertaintyEquals()
        {
            var u1 = new Uncertainty(0.6, 0.1, 0.2);
            var u2 = new Uncertainty(0.3, 0.1, 0.2);

            Assert.IsTrue(u1.Equals(u1));
            Assert.IsTrue(u1.Equals(u1.Clone()));
            Assert.IsFalse(u1.Equals(u2));
        }
コード例 #7
0
        public void TestUncertaintySqrt()
        {
            var u1 = new Uncertainty(9, 0.4);
            var u2 = u1.Sqrt();

            Assert.AreEqual(3, u2.Value);
            Assert.AreEqual(0.0666667, u2.UpperUncertainty, 0.000001);
            Assert.IsTrue(u2.IsRelative);
        }
コード例 #8
0
        public void TestUncertaintyCompare()
        {
            var u1 = new Uncertainty(0.8, 0.2, 0.1);
            var u2 = new Uncertainty(0.9, 0.2, 0.1);

            Assert.AreEqual(0, u1.CompareTo(u1.Clone()));
            Assert.AreEqual(-1, u1.CompareTo(u2));
            Assert.AreEqual(1, u2.CompareTo(u1));
        }
コード例 #9
0
        public void TestUncertaintyFromRange()
        {
            Uncertainty u = Uncertainty.FromRange(2, 1, 4);

            Assert.AreEqual(2, u.Value);
            Assert.AreEqual(1, u.LowerUncertainty);
            Assert.AreEqual(2, u.UpperUncertainty);
            Assert.IsFalse(u.IsRelative);
        }
コード例 #10
0
        public void TestUncertaintyFromPercentage()
        {
            Uncertainty u = Uncertainty.FromPercentage(2, 0, 1.25);

            Assert.AreEqual(2, u.Value);
            Assert.AreEqual(0, u.LowerUncertainty);
            Assert.AreEqual(2.5, u.UpperUncertainty);
            Assert.IsTrue(u.IsRelative);
        }
コード例 #11
0
        public void TestUncertaintyMin()
        {
            var u1 = new Uncertainty(4, 1, 0.5);
            var u2 = new Uncertainty(4, 0.5, 1);

            Assert.AreEqual(u1, u1.Min(u2));
            var u3 = new Uncertainty(2, 3, 3);

            Assert.AreEqual(u3, u2.Min(u3));
        }
コード例 #12
0
        public void TestUncertaintyIsConsistent()
        {
            var u1 = new Uncertainty(7, 0.6);
            var u2 = new Uncertainty(6, 0.5);
            var u3 = new Uncertainty(5, 0.5);

            Assert.IsTrue(u1.IsConsistent(u2));
            Assert.IsFalse(u1.IsConsistent(u3));
            Assert.IsTrue(u2.IsConsistent(u3));
        }
コード例 #13
0
        public void TestUncertaintyProperties()
        {
            var u = new Uncertainty(7.6, 1.1, 0.4);

            Assert.AreEqual(1.5, u.TotalUncertainty);
            Assert.AreEqual(6.5, u.Minimum);
            Assert.AreEqual(8.0, u.Maximum);
            Assert.AreEqual(0.1447368, u.LowerPercentage, 0.00001);
            Assert.AreEqual(0.0526316, u.UpperPercentage, 0.00001);
            Assert.IsFalse(u.IsSymmetric());
        }
コード例 #14
0
        public void TestUncertaintySubtractConstant()
        {
            var u1 = new Uncertainty(7.6, 0.2, 0.3);
            var u2 = u1.Subtract(7);

            Assert.AreEqual(u2, u1 - 7.0);
            Assert.AreEqual(-0.6, (7.0 - u1).Value, 0.00001);
            Assert.AreEqual(0.6, u2.Value, 0.00001);
            Assert.AreEqual(0.2, u2.LowerUncertainty);
            Assert.AreEqual(0.3, u2.UpperUncertainty);
            Assert.IsFalse(u2.IsRelative);
        }
コード例 #15
0
        public void TestUncertaintyMultiply()
        {
            var u1 = new Uncertainty(5, 0.5, 1.0);
            var u2 = new Uncertainty(2.2, 0.1, 0.1);
            var u3 = u1.Multiply(u2);

            Assert.AreEqual(u3, u1 * u2);
            Assert.AreEqual(11, u3.Value);
            Assert.AreEqual(1.6, u3.LowerUncertainty, 0.00001);
            Assert.AreEqual(2.7, u3.UpperUncertainty, 0.00001);
            Assert.IsTrue(u3.IsRelative);
        }
コード例 #16
0
        public void TestUncertaintyMultiplyConstant()
        {
            var u1 = new Uncertainty(7, 0.2, 0.7);
            var u2 = u1.Multiply(3);

            Assert.AreEqual(u2, u1 * 3);
            Assert.AreEqual(u2, 3 * u1);
            Assert.AreEqual(21, u2.Value);
            Assert.AreEqual(0.6, u2.LowerUncertainty, 0.00001);
            Assert.AreEqual(2.1, u2.UpperUncertainty, 0.00001);
            Assert.IsFalse(u2.IsRelative);
        }
コード例 #17
0
        public void TestUncertaintyDivide()
        {
            var u1 = new Uncertainty(12, 0.2, 1.0);
            var u2 = new Uncertainty(3, 0.1, 0.1);
            var u3 = u1.Divide(u2);

            Assert.AreEqual(u3, u1 / u2);
            Assert.AreEqual(4, u3.Value);
            Assert.AreEqual(0.2, u3.LowerUncertainty, 0.00001);
            Assert.AreEqual(0.466667, u3.UpperUncertainty, 0.00001);
            Assert.IsTrue(u3.IsRelative);
        }
コード例 #18
0
        public void TestUncertaintyAdd()
        {
            var u1 = new Uncertainty(6, 0.5, 0.2);
            var u2 = new Uncertainty(2.1, 0.1, 0.3);
            var u3 = u1.Add(u2);

            Assert.AreEqual(u3, u1 + u2);
            Assert.AreEqual(8.1, u3.Value);
            Assert.AreEqual(0.6, u3.LowerUncertainty);
            Assert.AreEqual(0.5, u3.UpperUncertainty);
            Assert.IsFalse(u3.IsRelative);
        }
コード例 #19
0
        public void TestUncertaintySymmetric()
        {
            var u1 = new Uncertainty(6, 0.5);
            var u2 = Uncertainty.FromPercentage(7, 0.10, 0.10);

            Assert.IsTrue(u1.IsSymmetric());
            Assert.AreEqual(u1.LowerUncertainty, u1.UpperUncertainty);
            Assert.AreEqual(u1.LowerPercentage, u1.UpperPercentage);
            Assert.IsTrue(u2.IsSymmetric());
            Assert.AreEqual(u2.LowerUncertainty, u2.UpperUncertainty);
            Assert.AreEqual(u2.LowerPercentage, u2.UpperPercentage);
        }
コード例 #20
0
        public void TestUncertaintyAddConstant()
        {
            var u1 = new Uncertainty(7.6, 0.2, 0.3);
            var u2 = u1.Add(7);

            Assert.AreEqual(u2, u1 + 7.0);
            Assert.AreEqual(u2, 7.0 + u1);
            Assert.AreEqual(14.6, u2.Value);
            Assert.AreEqual(0.2, u2.LowerUncertainty);
            Assert.AreEqual(0.3, u2.UpperUncertainty);
            Assert.IsFalse(u2.IsRelative);
        }
コード例 #21
0
        public void TestUncertaintySubtract()
        {
            var u1 = new Uncertainty(12, 1.1, 0.8);
            var u2 = new Uncertainty(4.3, 1, 0.2);
            var u3 = u1.Subtract(u2);

            Assert.AreEqual(u3, u1 - u2);
            Assert.AreEqual(7.7, u3.Value);
            Assert.AreEqual(2.1, u3.LowerUncertainty);
            Assert.AreEqual(1.0, u3.UpperUncertainty);
            Assert.IsFalse(u3.IsRelative);
        }
コード例 #22
0
        public void TestUncertaintyNegate()
        {
            var u1 = new Uncertainty(6.2, 0.9, 0.1);
            var u2 = u1.Negate();

            Assert.AreEqual(u2, -u1);
            Assert.AreEqual(u2, u1 * -1);
            Assert.AreEqual(-6.2, u2.Value);
            Assert.AreEqual(0.9, u2.LowerUncertainty);
            Assert.AreEqual(0.1, u2.UpperUncertainty);
            Assert.IsFalse(u2.IsRelative);
        }
コード例 #23
0
        public void TestUncertaintyDivideConstant()
        {
            var u1 = new Uncertainty(6, 0.3, 0.2);
            var u2 = u1.Divide(3);

            Assert.AreEqual(u2, u1 / 3);
            Assert.AreEqual(0.5, (3 / u1).Value, 0.00001);
            Assert.AreEqual(2, u2.Value);
            Assert.AreEqual(0.1, u2.LowerUncertainty, 0.00001);
            Assert.AreEqual(0.0666667, u2.UpperUncertainty, 0.00001);
            Assert.IsFalse(u2.IsRelative);
        }
コード例 #24
0
        public void TestUncertaintyPow()
        {
            var u1 = new Uncertainty(2, 0.2);

            Assert.AreEqual(0.1, u1.UpperPercentage);
            Assert.IsFalse(u1.IsRelative);
            var u2 = u1.Pow(2);

            Assert.AreEqual(4, u2.Value);
            Assert.AreEqual(0.2, u2.UpperPercentage);
            Assert.AreEqual(0.8, u2.UpperUncertainty);
            Assert.IsTrue(u2.IsRelative);
        }
コード例 #25
0
ファイル: frmMain.cs プロジェクト: xiaozangyu/STKCodeExamples
        private void btnRunAnalysis_Click(object sender, EventArgs e)
        {
            resultList = new List <PropagationResults>();
            // define the uncertainty level
            uncertainty = new Uncertainty(Convert.ToDouble(tbIntrackPosUnc.Text), Convert.ToDouble(tbRadialPosUnc.Text), Convert.ToDouble(tbCrosstrackPosUnc.Text),
                                          Convert.ToDouble(tbIntrackVelUnc.Text), Convert.ToDouble(tbRadialVelUnc.Text), Convert.ToDouble(tbCrosstrackVelUnc.Text));
            // get the number of runs
            nRuns = Convert.ToDouble(this.nudNRuns.Value);
            try
            {
                // get the propagator to use
                if (this.cbPropagator.SelectedItem.ToString().Equals("Jacchia-Roberts"))
                {
                    propagatorName = "Jacchia-Roberts";
                }
                else if (this.cbPropagator.SelectedItem.ToString().Equals("NRLMSISE 2000"))
                {
                    propagatorName = "NRLMSISE 2000";
                }

                this.tbEventLogger.AppendText("Reentry analysis - Input data" + Environment.NewLine);
                this.tbEventLogger.AppendText("Satellite catalog number: " + currentTle.GetSatNumber() + Environment.NewLine);
                this.tbEventLogger.AppendText("TLE epoch: " + currentTle.GetTleEpoch() + Environment.NewLine);
                this.tbEventLogger.AppendText("Satellite mass: " + this.tbMass.Text + Environment.NewLine);
                this.tbEventLogger.AppendText("Density model: " + this.cbPropagator.SelectedItem.ToString() + Environment.NewLine);
                this.tbEventLogger.AppendText("Satellite drag area: " + this.tbDragArea.Text + Environment.NewLine);
                this.tbEventLogger.AppendText("Drag coefficient: " + this.tbCd.Text + Environment.NewLine);
                this.tbEventLogger.AppendText("Satellite solar area: " + this.tbSolarArea.Text + Environment.NewLine);
                this.tbEventLogger.AppendText("SRP coefficient: " + this.tbCr.Text + Environment.NewLine);
                this.tbEventLogger.AppendText(Environment.NewLine);

                // create an instance of the BackgroundWorker class
                BackgroundWorker bw = new BackgroundWorker();
                bw.WorkerReportsProgress = true;

                // add the event handlers to the BackgroundWorker instance's events
                bw.DoWork             += new DoWorkEventHandler(runAnalysisDoWork);
                bw.ProgressChanged    += new ProgressChangedEventHandler(runAnalysisProgressChanged);
                bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(runAnalysisCompleted);

                this.progressBar.Style = ProgressBarStyle.Blocks;
                this.statusLabel.Text  = "Analysis started...";
                // start running the background operation by calling the RunWorkerAsync method.
                bw.RunWorkerAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please select a propagator type", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
コード例 #26
0
        public void TestUncertaintyDivideConstantRelative()
        {
            var u1 = Uncertainty.FromPercentage(8, 0.1, 0.2);
            var u2 = u1.Divide(2);

            Assert.AreEqual(u2, u1 / 2);
            Assert.AreEqual(0.25, (2 / u1).Value, 0.00001);
            Assert.AreEqual(4, u2.Value);
            Assert.AreEqual(0.1, u2.LowerPercentage, 0.00001);
            Assert.AreEqual(0.2, u2.UpperPercentage, 0.00001);
            Assert.AreEqual(0.4, u2.LowerUncertainty, 0.00001);
            Assert.AreEqual(0.8, u2.UpperUncertainty, 0.00001);
            Assert.IsTrue(u2.IsRelative);
        }
コード例 #27
0
        public void TestUncertaintyMultiplyConstantRelative()
        {
            var u1 = Uncertainty.FromPercentage(8, 0.2, 0.3);
            var u2 = u1.Multiply(2);

            Assert.AreEqual(u2, u1 * 2);
            Assert.AreEqual(u2, 2 * u1);
            Assert.AreEqual(16, u2.Value);
            Assert.AreEqual(0.2, u2.LowerPercentage, 0.00001);
            Assert.AreEqual(0.3, u2.UpperPercentage, 0.00001);
            Assert.AreEqual(3.2, u2.LowerUncertainty, 0.00001);
            Assert.AreEqual(4.8, u2.UpperUncertainty, 0.00001);
            Assert.IsTrue(u2.IsRelative);
        }
コード例 #28
0
        public void TestUncertaintyToStringRelative()
        {
            var u1 = Uncertainty.FromPercentage(2, 0.05, 0.1);

            Assert.AreEqual("2 (+5%, -10%)", u1.ToString());
            Assert.AreEqual("2 (+5%, -10%)", u1.ToString("G", null));
            Assert.AreEqual("2 (+0.1, -0.2)", u1.ToString("A", null));
            Assert.AreEqual("2 (+5%, -10%)", u1.ToString("R", null));
            Assert.AreEqual("2.0 (+5.0%, -10.0%)", u1.ToString("RF1", null));
            Assert.AreEqual("2 (+5%, -10%)", u1.ToString("T", null));
            Assert.AreEqual("2", u1.ToString("V", null));
            Assert.AreEqual("(2 (+5%, -10%))", u1.ToString("B", null));
            Assert.AreEqual("2 +5%, -10%", u1.ToString("N", null));
            Assert.AreEqual("2 {0} (+5%, -10%)", u1.ToString("F", null));
        }
コード例 #29
0
        public void TestUncertaintyToString()
        {
            var u1 = new Uncertainty(3.2, 0.5);

            Assert.AreEqual("3.2 (±0.5)", u1.ToString());
            Assert.AreEqual("3.2 (±0.5)", u1.ToString("G", null));
            Assert.AreEqual("3.2 (±0.5)", u1.ToString("A", null));
            Assert.AreEqual("3.2 (±15.625%)", u1.ToString("R", null));
            Assert.AreEqual("3.2 (±15.6%)", u1.ToString("RF1", null));
            Assert.AreEqual("3.2 (+-0.5)", u1.ToString("T", null));
            Assert.AreEqual("3.2", u1.ToString("V", null));
            Assert.AreEqual("(3.2 (±0.5))", u1.ToString("B", null));
            Assert.AreEqual("3.2 ±0.5", u1.ToString("N", null));
            Assert.AreEqual("3.2 (±0.5) {0}", u1.ToString("F", null));
        }
コード例 #30
0
        public void TestUncertaintyEquality()
        {
            var u1 = new Uncertainty(3, 0.1);
            var u2 = new Uncertainty(4, 0.1);
            var u3 = new Uncertainty(5, 0.3);
            var u4 = new Uncertainty(3, 0.2);

            Assert.IsTrue(u2 > u1);
            Assert.IsTrue(u3 >= u2);
            Assert.IsFalse(u1 > u4);

            Assert.IsTrue(u2 < u3);
            Assert.IsTrue(u4 <= u3);

            Assert.IsFalse(u4 == u1);
            Assert.IsFalse(u3 == u2);
            Assert.IsTrue(u3 == u3.Clone());
        }