Beispiel #1
0
        public void Radians_Parse_FromPi_Negative()
        {
            var value1 = Radians.Parse("-1 pi");

            TheResultingValue(value1).ShouldBe(-(float)Math.PI);

            var value1sym = Radians.Parse("-1π");

            TheResultingValue(value1sym).ShouldBe(-(float)Math.PI);

            var value2 = Radians.Parse("-2 pi");

            TheResultingValue(value2).ShouldBe(-(float)(2.0 * Math.PI));

            var value2sym = Radians.Parse("-2π");

            TheResultingValue(value2sym).ShouldBe(-(float)(2.0 * Math.PI));

            var value3 = Radians.Parse("-1/2 pi");

            TheResultingValue(value3).ShouldBe(-(float)(0.5 * Math.PI));

            var value3sym = Radians.Parse("-1/2π");

            TheResultingValue(value3sym).ShouldBe(-(float)(0.5 * Math.PI));
        }
Beispiel #2
0
        /// <summary>
        ///     <para/>Racunanje slobodnog clana za matricu slobodnih clanova, preko izmjerenog azimuta i azimuta izracunatog iz koordinata
        /// </summary>
        /// <param name="stajaliste">Tocka stajalista instrumenta</param>
        /// <param name="vizura">Tocka vizure instrumenta</param>
        /// <param name="izmjereniAzimut">Azimut (smjerni kut, direkcioni ugao) izmjeren na terenu</param>
        /// <exception cref="ArgumentException">Baca se kada su koordinate obe tocke iste</exception>
        /// <exception cref="ArgumentOutOfRangeException">Baca se kada mjereni azimut nije u intervalu od 0 do 2*PI</exception>
        public AzimutSlobodanClan(ITockaProjekcija stajaliste, ITockaProjekcija vizura, Radians izmjereniAzimut)
        {
            exceptionIsteKoordinateTocke(stajaliste, vizura);
            exceptionOdNulaDo2PI(izmjereniAzimut);

            f = slobodanClan(stajaliste, vizura, izmjereniAzimut);
        }
Beispiel #3
0
        public void Radians_Constructor_Gradians_ReturnsTrue()
        {
            Radians kut     = new Radians(Math.PI / 4);
            Radians kutTest = new Radians(new Gradians(50));

            Assert.IsTrue((kut - kutTest).Angle < tolerance);
        }
Beispiel #4
0
        public void Degrees_Implicit_Radians_ReturnsTrue()
        {
            Degrees dms = new Degrees(180 / 5);
            Radians rad = dms;

            Assert.IsTrue(rad.Angle == Math.PI / 5);
        }
Beispiel #5
0
        public void HMS_Implicit_Radians_ReturnsTrue()
        {
            HMS     hms = new HMS(12, 0, 0);
            Radians rad = hms;

            Assert.IsTrue(rad.Angle == Math.PI, rad.Angle.ToString());
        }
        public void Can_compare_for_less_than(double a, double b, bool expectedResult)
        {
            var radian1 = Radians.FromRaw(a);
            var radian2 = Radians.FromRaw(b);

            Assert.Equal(expectedResult, radian1 < radian2);
        }
        public void Can_preform_modulo(double value, double mod, double expectedResult)
        {
            var radianVal = Radians.FromRaw(value);
            var radianMod = Radians.FromRaw(mod);

            Assert.Equal(Radians.FromRaw(expectedResult), radianVal % radianMod);
        }
        public void Can_subtract(double a, double b, double result)
        {
            var radian1 = Radians.FromRaw(a);
            var radian2 = Radians.FromRaw(b);

            Assert.Equal(Radians.FromRaw(result), radian1 - radian2);
        }
Beispiel #9
0
        public void Hours_Implicit_Radians_ReturnsTrue()
        {
            Hours   dms = new Hours(12 / 3);
            Radians rad = dms;

            Assert.IsTrue(rad.Angle == Math.PI / 3);
        }
        /// <summary>
        /// Updates the transform's cached value.
        /// </summary>
        private void UpdateValue()
        {
            var centerX = (Single)CenterX;
            var centerY = (Single)CenterY;

            var degrees = MathUtil.IsApproximatelyZero(Angle % 360) ? 0f : Angle;
            var radians = Radians.FromDegrees(degrees);

            var hasCenter = (centerX != 0 || centerY != 0);

            if (hasCenter)
            {
                var mtxRotate                 = Matrix.CreateRotationZ(radians);
                var mtxTransformCenter        = Matrix.CreateTranslation(-centerX, -centerY, 0f);
                var mtxTransformCenterInverse = Matrix.CreateTranslation(centerX, centerY, 0f);

                Matrix mtxResult;
                Matrix.Concat(ref mtxTransformCenter, ref mtxRotate, out mtxResult);
                Matrix.Concat(ref mtxResult, ref mtxTransformCenterInverse, out mtxResult);

                this.value = mtxResult;
            }
            else
            {
                this.value = Matrix.CreateRotationZ(radians);
            }

            Matrix invertedValue;

            this.inverse    = Matrix.TryInvert(value, out invertedValue) ? invertedValue : (Matrix?)null;
            this.isIdentity = Matrix.Identity.Equals(value);
        }
Beispiel #11
0
        public void Radians_Parse_FromTau()
        {
            var value1 = Radians.Parse("1 tau");

            TheResultingValue(value1).ShouldBe((float)(2.0 * Math.PI));

            var value1sym = Radians.Parse("1τ");

            TheResultingValue(value1sym).ShouldBe((float)(2.0 * Math.PI));

            var value2 = Radians.Parse("2 tau");

            TheResultingValue(value2).ShouldBe((float)(4.0 * Math.PI));

            var value2sym = Radians.Parse("2τ");

            TheResultingValue(value2sym).ShouldBe((float)(4.0 * Math.PI));

            var value3 = Radians.Parse("1/2 tau");

            TheResultingValue(value3).ShouldBe((float)Math.PI);

            var value3sym = Radians.Parse("1/2τ");

            TheResultingValue(value3sym).ShouldBe((float)Math.PI);
        }
Beispiel #12
0
        public void DMS_Implicit_Radians_ReturnsTrue()
        {
            DMS     dms = new DMS(180, 0, 0);
            Radians rad = dms;

            Assert.IsTrue(rad.Angle == Math.PI);
        }
Beispiel #13
0
        private void DoTeleport()
        {
            CharacterStatus status = this.character.status;

            // End the Teleport Action (to prevent re-teleportation)
            this.character.status.action.EndAction(this.character);

            // Get X, Y Coordinates from Distance and Radian
            float trueRotation = Radians.Normalize(status.actionFloat1);
            int   xCoord       = (int)Radians.GetXFromRotation(trueRotation, status.actionNum1) + character.posX + character.bounds.MidX;
            int   yCoord       = (int)Radians.GetYFromRotation(trueRotation, status.actionNum1) + character.posY + character.bounds.MidY;

            // Make sure teleportation is within world bounds.
            if (yCoord < (byte)TilemapEnum.GapUpPixel || yCoord > this.character.room.Height + (byte)TilemapEnum.GapUpPixel || xCoord < (byte)TilemapEnum.GapLeftPixel || xCoord > this.character.room.Width + (byte)TilemapEnum.GapRightPixel)
            {
                this.character.room.PlaySound(Systems.sounds.disableCollectable, 0.5f, this.character.posX + 16, this.character.posY + 16);
                return;
            }

            TilemapLevel tilemap = character.room.tilemap;

            // Make sure teleportation is to a valid open area. Blocking tiles will prevent teleportation.
            int xMid = xCoord - this.character.bounds.MidX;
            int yMid = yCoord - this.character.bounds.MidY;

            bool upLeft    = CollideTile.IsBlockingCoord(tilemap, xMid + character.bounds.Left, yMid + character.bounds.Top - 1, DirCardinal.None);
            bool upRight   = CollideTile.IsBlockingCoord(tilemap, xMid + character.bounds.Right, yMid + character.bounds.Bottom - 1, DirCardinal.None);
            bool downLeft  = CollideTile.IsBlockingCoord(tilemap, xMid + character.bounds.Left, yMid + character.bounds.Top - 1, DirCardinal.None);
            bool downRight = CollideTile.IsBlockingCoord(tilemap, xMid + character.bounds.Right, yMid + character.bounds.Bottom - 1, DirCardinal.None);

            // If all positions are blocked, prevent teleport.
            if (upLeft && upRight && downLeft && downRight)
            {
                this.character.room.PlaySound(Systems.sounds.disableCollectable, 0.5f, this.character.posX + 16, this.character.posY + 16);
                return;
            }

            // If some positions are blocked, adjust position:
            if (upLeft && downLeft)
            {
                xMid += 12;
            }
            if (upRight && downRight)
            {
                xMid -= 12;
            }
            if (upLeft && upRight)
            {
                yMid += 12;
            }
            if (downLeft && downRight)
            {
                yMid -= 12;
            }

            this.character.room.PlaySound(Systems.sounds.pop, 1f, this.character.posX + 16, this.character.posY + 16);

            // Teleport Character
            this.character.physics.MoveToPos(xMid, yMid);
        }
Beispiel #14
0
        private double[] applyInverted(double[] p)
        {
            double[] result = new double[p.Length];

            int delta = 2;

            if (p.Length % 3 == 0)
            {
                delta = 3;
            }

            for (int i = 0; i < p.Length / 2; i += delta)
            {
                if (delta == 3)
                {
                    result[i + 2] = p[i + 2];
                }

                Vector3 vector = _center + _xAxis * p[i] + _yAxis * p[i + 1];
                result[i + 1] = Radians.ToDegrees(UnitSphere.Latitude(vector));
                result[i]     = Radians.ToDegrees(UnitSphere.Longitude(vector));
            }

            return(result);
        }
Beispiel #15
0
        public void CalculateTest(double first, double expected)
        {
            var calculator   = new Radians();
            var actualResult = calculator.CalculateTwo(first);

            Assert.AreEqual((int)expected, (int)actualResult);
        }
Beispiel #16
0
        public Direction2D(Radians angle)
        {
            float radians   = angle.FloatAsRadians();
            float increment = (radians / Mathf.PI) * 8;
            var   nibble    = Nibble.Zero;

            if (increment < 3 || increment > 13)
            {
                nibble |= (Nibble)CONST_RIGHT;
            }

            if (increment < 7 && increment > 1)
            {
                nibble |= (Nibble)CONST_UP;
            }

            if (increment < 11 && increment > 5)
            {
                nibble |= (Nibble)CONST_LEFT;
            }

            if (increment < 15 && increment > 9)
            {
                nibble |= (Nibble)CONST_DOWN;
            }

            this.value = nibble;
        }
Beispiel #17
0
 public GameObject(Vector2 position, float rotationDegrees = 0.0f, float scale = 1.0f)
 {
     Position        = position;
     RotationRadians = Radians.FromDegrees(rotationDegrees);
     Scale           = scale;
     _components     = new HashSet <IComponent>();
 }
Beispiel #18
0
        public void Radians_Arithmetic_promjenaPredznaka_ReturnsTrue()
        {
            Radians a = new Radians(1);

            Radians b = -a;

            Assert.IsTrue(b.Angle < 0, "Predznak: " + b);
        }
Beispiel #19
0
        public void RadiansFunctionWithInputZeroDegreesReturnsCorrectResult()
        {
            var func   = new Radians();
            var args   = FunctionsHelper.CreateArgs(0);
            var result = func.Execute(args, this.ParsingContext);

            Assert.AreEqual(0.0, result.Result);
        }
Beispiel #20
0
        public void RadiansFunctionWithTooFewArgumentsReturnsPoundValue()
        {
            var func   = new Radians();
            var args   = FunctionsHelper.CreateArgs();
            var result = func.Execute(args, this.ParsingContext);

            Assert.AreEqual(eErrorType.Value, ((ExcelErrorValue)result.Result).Type);
        }
        /// <inheritdoc/>
        protected override void OnClick(EventArgs e)
        {
            Radians = (Radians)radians;

            editorService.CloseDropDown();

            base.OnClick(e);
        }
Beispiel #22
0
        public void ToGradians_200_ReturnsTrue()
        {
            Radians kutRadijani = new Radians(Math.PI);

            Gradians kutZaProvjeru = new Gradians(200);

            Assert.IsTrue(kutRadijani.ToGradians().Angle == kutZaProvjeru.Angle);
        }
Beispiel #23
0
        /// <inheritdoc/>
        protected override void OnClick(EventArgs e)
        {
            Radians = (Radians)radians;

            editorService.CloseDropDown();

            base.OnClick(e);
        }
Beispiel #24
0
        /// <summary>
        /// <para/>Racunanje slobodnog clana za matricu slobodnih clanova, preko izmjerenog pravca i orijentacije i smjernog kuta (direkcionog ugla) izracunatog iz koordinata
        /// </summary>
        /// <param name="stajaliste">Tocka stajalista instrumenta</param>
        /// <param name="vizura">Tocka vizure instrumenta</param>
        /// <param name="izmjereniPravac">Pravac izmjeren na terenu</param>
        /// <param name="orijentacija">Pravac orijentacije (nule) limba</param>
        /// <exception cref="ArgumentException">Baca se kada su koordinate obe tocke iste</exception>
        /// <exception cref="ArgumentOutOfRangeException">Baca se kada mjereni pravac nije u intervalu od 0 do 2*PI</exception>
        public PravacSlobodanClan(ITockaProjekcija stajaliste, ITockaProjekcija vizura, IRadian izmjereniPravac, IRadian orijentacija)
        {
            exceptionIsteKoordinateTocke(stajaliste, vizura);
            exceptionOdNulaDo2PI(izmjereniPravac);
            exceptionOdNulaDo2PI(orijentacija);

            f = slobodanClan(stajaliste, vizura, izmjereniPravac, orijentacija);
        }
Beispiel #25
0
 /// <inheritdoc/>
 public override Object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
 {
     if (value is String)
     {
         return(Radians.Parse((String)value));
     }
     return(base.ConvertFrom(context, culture, value));
 }
Beispiel #26
0
        public void ToDegrees_180_ReturnsTrue()
        {
            Radians kutRadijani = new Radians(Math.PI);

            Degrees kutZaProvjeru = new Degrees(180);

            Assert.IsTrue(kutRadijani.ToDegrees().Angle == kutZaProvjeru.Angle);
        }
Beispiel #27
0
 public override bool Equals(object obj)
 {
     if (!(obj is Angle))
     {
         return(false);
     }
     return(Radians.NearlyEquals(((Angle)obj).Radians));
 }
Beispiel #28
0
        public void GlavnaMjeraKutaPozitivanSmjer_PI_ReturnsTrue()
        {
            Radians kutRadijani = new Radians(-3 * Math.PI);

            double difference = Math.Abs(kutRadijani.GlavnaMjeraKutaPozitivanSmjer() - Math.PI);

            Assert.IsTrue(difference < tolerance);
        }
Beispiel #29
0
        public void Correctly_converts_radians_from_degrees()
        {
            var degrees = Degrees.FromRaw(180);

            var angle = Angle.From(degrees);

            Assert.Equal(Radians.FromRaw(Math.PI), angle.Radians);
        }
Beispiel #30
0
        public void Correctly_converts_degrees_from_radians()
        {
            var radians = Radians.FromRaw(Math.PI);

            var angle = Angle.From(radians);

            Assert.Equal(Degrees.FromRaw(180), angle.Degrees);
        }
Beispiel #31
0
        public void Can_create_from_radians()
        {
            var radians = Radians.FromRaw(Math.PI);

            var angle = Angle.From(radians);

            Assert.Equal(radians, angle.Radians);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="RadiansEditorControl"/> class.
        /// </summary>
        /// <param name="radians">The <see cref="Radians"/> value to edit.</param>
        /// <param name="editorService">The editor service which is controlling the editor.</param>
        public RadiansEditorControl(Radians radians, IWindowsFormsEditorService editorService)
        {
            Radians = radians;

            DoubleBuffered = true;

            this.editorService = editorService;

            InitializeComponent();

            RecalculateSelectionCircle();
        }
Beispiel #33
0
 /// <summary>
 /// Initializes a new instance of the RadiansResult class.
 /// </summary>
 /// <param name="value">The value being examined.</param>
 internal RadiansResult(Radians value)
 {
     this.value = value;
 }
 /// <summary>
 /// Wraps the specified unit test result for evaluation.
 /// </summary>
 /// <param name="value">The value to wrap.</param>
 /// <returns>The wrapped value.</returns>
 protected static RadiansResult TheResultingValue(Radians value)
 {
     return new RadiansResult(value);
 }