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)); }
/// <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); }
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); }
public void Degrees_Implicit_Radians_ReturnsTrue() { Degrees dms = new Degrees(180 / 5); Radians rad = dms; Assert.IsTrue(rad.Angle == Math.PI / 5); }
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); }
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); }
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); }
public void DMS_Implicit_Radians_ReturnsTrue() { DMS dms = new DMS(180, 0, 0); Radians rad = dms; Assert.IsTrue(rad.Angle == Math.PI); }
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); }
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); }
public void CalculateTest(double first, double expected) { var calculator = new Radians(); var actualResult = calculator.CalculateTwo(first); Assert.AreEqual((int)expected, (int)actualResult); }
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; }
public GameObject(Vector2 position, float rotationDegrees = 0.0f, float scale = 1.0f) { Position = position; RotationRadians = Radians.FromDegrees(rotationDegrees); Scale = scale; _components = new HashSet <IComponent>(); }
public void Radians_Arithmetic_promjenaPredznaka_ReturnsTrue() { Radians a = new Radians(1); Radians b = -a; Assert.IsTrue(b.Angle < 0, "Predznak: " + b); }
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); }
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); }
public void ToGradians_200_ReturnsTrue() { Radians kutRadijani = new Radians(Math.PI); Gradians kutZaProvjeru = new Gradians(200); Assert.IsTrue(kutRadijani.ToGradians().Angle == kutZaProvjeru.Angle); }
/// <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); }
/// <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)); }
public void ToDegrees_180_ReturnsTrue() { Radians kutRadijani = new Radians(Math.PI); Degrees kutZaProvjeru = new Degrees(180); Assert.IsTrue(kutRadijani.ToDegrees().Angle == kutZaProvjeru.Angle); }
public override bool Equals(object obj) { if (!(obj is Angle)) { return(false); } return(Radians.NearlyEquals(((Angle)obj).Radians)); }
public void GlavnaMjeraKutaPozitivanSmjer_PI_ReturnsTrue() { Radians kutRadijani = new Radians(-3 * Math.PI); double difference = Math.Abs(kutRadijani.GlavnaMjeraKutaPozitivanSmjer() - Math.PI); Assert.IsTrue(difference < tolerance); }
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); }
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); }
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(); }
/// <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); }