private void populateThis(Point StartPoint, Azimuth incomingDir, Deflection defl, Double radius) { Origin = StartPoint; Rotation = incomingDir; Deflection = defl; Azimuth BegRadiusDirection = incomingDir + new Deflection(Math.PI / 2.0, -1 * Deflection.deflectionDirection); BeginRadiusVector = new Vector( direction: BegRadiusDirection, length: radius); CenterPt = StartPoint - BeginRadiusVector; EndRadiusVector = BeginRadiusVector + Deflection; // Conic Section components Eccentricity = 0.0; a = b = Radius = BeginRadiusVector.Length; // Path Components StartPt = StartPoint; EndPt = CenterPt + EndRadiusVector; StartAzimuth = incomingDir; EndAzimuth = StartAzimuth + Deflection; Length = (Deflection.angle_ / Math.PI) * Radius; // Graphic Components not already set ScaleVector = new Vector(Azimuth.ctorAzimuthFromDegree(45.0), Radius); computeBoundingBox(); }
/// <inheritdoc/> public override void RunCombination(int combinationIndex, Combination combination, CalculationContext context) { Shear.Run(context); Moment.Run(context); Axial.Run(context); Deflection.Run(context); }
private void Update() { Quaternion destination; if (target != null) { Vector2 direction; var movingUnit = target as MovingUnit; if (movingUnit == null) { direction = target.position - (Vector2)gunTransform.position; } else { direction = Deflection.CalculateDirection(gunTransform.position, target.position, machineGun.bulletSpeed, movingUnit.velocityTrend); } destination = GetClampedLookRotation(direction); } else { destination = Quaternion.LookRotation(Vector3.forward, initialDirection); } gunTransform.rotation = Quaternion.RotateTowards(gunTransform.rotation, destination, rotationSpeed * Time.deltaTime); machineGun.isTriggerPressed = target != null; }
public static void CheckWallAndDeflect <T>(T o, PlayArena arena, Deflection deflect) where T : GameObject { if (!o.IsAlive) { return; } Direction d; CollisionPoint c; var l = new Rectangle(arena.Bounds.Left, arena.Bounds.Top, 0, arena.Bounds.Height); var r = new Rectangle(arena.Bounds.Right, arena.Bounds.Top, 0, arena.Bounds.Height); var t = new Rectangle(arena.Bounds.Left, arena.Bounds.Top, arena.Bounds.Width, 0); if (IsCollision(o, l, out d, out c)) { deflect(c, Direction.Left); } else if (IsCollision(o, r, out d, out c)) { deflect(c, Direction.Right); } else if (IsCollision(o, t, out d, out c)) { deflect(c, Direction.Up); } }
public void Azimuth_Arithmatic_addition() { Tuple <Double, Double, Double>[] testCases = { new Tuple <Double, Double, Double>(20.0, 10.0, -10.0), new Tuple <Double, Double, Double>(340.0, 350.0, 10.0), new Tuple <Double, Double, Double>(20.0, 340.0, -40.0), new Tuple <Double, Double, Double>(340.0, 20.0, 40.0), new Tuple <Double, Double, Double>(189.4326, 173.8145, -15.6181), }; foreach (var testCase in testCases) { Double Az1Dbl = testCase.Item1; Double ExpectedAz2Dbl = testCase.Item2; Double DeflectionDbl = testCase.Item3; Azimuth Az1 = new Azimuth(); Az1.setFromDegreesDouble(Az1Dbl); Deflection defl = DeflectionDbl.AsPtsDegree(); Azimuth Az2 = Az1 + defl; Double actualAzimuth = Az2.getAsDegreesDouble(); Assert.AreEqual(expected: ExpectedAz2Dbl, actual: actualAzimuth, delta: 0.00000001); } }
public void Deflection_positiveLessThan180_getAsRadians() { Double expectedValue = 0.785398164; Deflection defl = new Deflection(0.785398164, 1); Double actualValue = defl.getAsRadians(); Assert.AreEqual(expected: expectedValue, actual: actualValue, delta: 0.00001); }
public void Deflection_positiveGreaterThan180_getAsRadians() { Double expectedValue = 5.41052068118; Deflection defl = new Deflection(5.41052068118, 1); Double actualValue = defl.getAsRadians(); Assert.AreEqual(expected: expectedValue, actual: actualValue, delta: 0.00001); }
public void Deflection_negativeGreaterThan180_getAsDegrees() { Double expectedValue = -310.0; Deflection defl = new Deflection(5.41052068118, -1); Double actualValue = defl.getAsDegreesDouble(); Assert.AreEqual(expected: expectedValue, actual: actualValue, delta: 0.00001); }
public void Deflection_negativeLessThan180_getAsDegrees() { Double expectedValue = -45.0; Deflection defl = new Deflection(0.785398164, -1); Double actualValue = defl.getAsDegreesDouble(); Assert.AreEqual(expected: expectedValue, actual: actualValue, delta: 0.00001); }
public void Azimuth_Addition_Az189PlusDeflNeg15_shouldEqual174() { Double expectedDbl = 174.0; Azimuth az = new Azimuth(); az.setFromDegreesDouble(189.0); Deflection defl = new Deflection(); defl.setFromDegreesDouble(-15.0); Azimuth newAz = az + defl; Double actualDbl = newAz.getAsDegreesDouble(); Assert.AreEqual(expected: expectedDbl, actual: actualDbl, delta: delta); }
public void Deflection_negativeLessThan180_getAsRadians() { Double expectedValue = -0.39479111970; Azimuth begAz = new Azimuth(new Point(0.0, 0.0, 0.0), new Point(10.0, 50.0, 0.0)); Azimuth endAz = new Azimuth(new Point(10.0, 50.0, 0.0), new Point(0.0, 100.0, 0.0)); Deflection defl = new Deflection(begAz, endAz, true); Double actualValue = defl.getAsRadians(); Assert.AreEqual(expected: expectedValue, actual: actualValue, delta: 0.0000001); }
public double GetConstructingTime(GearBoxType gearBox) { gearBox.GetReadyTime = Deflection.Do(gearBox.GetReadyTime, gearBox.GetReadyTimeDeflection); gearBox.ConstructingTime = Deflection.Do(gearBox.ConstructingTime, gearBox.ConstructingTimeDeflection); gearBox.FinishingTime = Deflection.Do(gearBox.FinishingTime, gearBox.FinishingTimeDeflection); double constructingTime = gearBox.GetReadyTime + gearBox.ConstructingTime + gearBox.FinishingTime; PrintConstructingTime(gearBox.GetReadyTime, gearBox.ConstructingTime, gearBox.FinishingTime); return(constructingTime); }
public void Deflection_setTo_Pos6Rad_shouldBe_Pos6Rad() { Deflection aDefl = new Deflection(); aDefl = (Deflection)6.0; Double expected = 6.0; Double actual = aDefl.getAsRadians(); Assert.AreEqual(expected: expected, actual: actual, delta: delta); }
public void Deflection_setTo_neg5__18__29_5() { Deflection aDeflection = new Deflection(); aDeflection.setFromDegreesMinutesSeconds(-5, 18, 29.5); Double expected = -5.308194444444; Double actual = aDeflection.getAsDegreesDouble(); Assert.AreEqual(expected: expected, actual: actual, delta: delta); }
public void Arc_CreateArc_ctor3DeflectingRight90_IsCorrect() { var anArc = new Arc(new Point(100.0, 100.0), Azimuth.ctorAzimuthFromDegree(90), Deflection.ctorDeflectionFromAngle(90.0, 1), 50.0); Assert.IsNotNull(anArc); Assert.AreEqual( expected: 0.0, actual: anArc.BeginRadiusVector.Azimuth.getAsDegreesDouble(), delta: 0.00001); Assert.AreEqual( expected: 90.0, actual: anArc.StartAzimuth.getAsDegreesDouble(), delta: 0.00001); Assert.IsNotNull(anArc.BoundingBox); Assertt.AreEqual( expected: new Point(100, 50), actual: anArc.CenterPt); Assert.AreEqual( expected: 90.0, actual: anArc.Deflection.getAsDegreesDouble(), delta: 0.00001); Assert.AreEqual( expected: 0.0, actual: anArc.Eccentricity, delta: 0.00001); Assertt.AreEqual( expected: new Point(150.0, 50.0), actual: anArc.EndPt); var expecVec = new Vector(Azimuth.ctorAzimuthFromDegree(90.0), 50.0); Assertt.AreEqual( expected: expecVec, actual: anArc.EndRadiusVector); Assertt.AreEqual( expected: new Point(100.0, 100.0), actual: anArc.Origin); Assert.AreEqual( expected: 50.0, actual: anArc.Radius, delta: 0.00001); Assert.AreEqual( expected: 0.0, actual: anArc.Rotation.getAsDegreesDouble(), delta: 0.00001); Double FiftyOverSR2 = 50.0 / Math.Sqrt(2.0); Assertt.AreEqual( expected: new Vector(FiftyOverSR2, FiftyOverSR2), actual: anArc.ScaleVector); }
public void Deflection_setTo_Pos2_shouldBe_Pos2Degrees() { Deflection defl = new Deflection(); defl.setFromDegreesDouble(2.0); Double expected = 2.0; Double actual = defl.getAsDegreesDouble(); Assert.AreEqual(expected: expected, actual: actual, delta: delta); }
public void Arc_CreateArc_ctor3DeflectingLeft90_IsCorrect() { var anArc = new Arc(new Point(100.0, 100.0), Azimuth.ctorAzimuthFromDegree(90), Deflection.ctorDeflectionFromAngle(90.0, -1), 50.0); Assert.IsNotNull(anArc); Assert.AreEqual( expected: 180.0, actual: anArc.BeginRadiusVector.Azimuth.getAsDegreesDouble(), delta: 0.00001, message: "BeginRadiusVector"); Assert.AreEqual( expected: 90.0, actual: anArc.StartAzimuth.getAsDegreesDouble(), delta: 0.00001, message: "BeginPointAngle"); Assert.IsNotNull(anArc.BoundingBox); Assertt.AreEqual( expected: new Point(100, 150), actual: anArc.CenterPt); Assert.AreEqual( expected: -90.0, actual: anArc.Deflection.getAsDegreesDouble(), delta: 0.00001, message: "Deflection"); Assert.AreEqual( expected: 0.0, actual: anArc.Eccentricity, delta: 0.00001, message: "Eccentricity"); Assertt.AreEqual( expected: new Point(150.0, 150.0), actual: anArc.EndPt); var expecVec = new Vector(Azimuth.ctorAzimuthFromDegree(90.0), 50.0); Assertt.AreEqual( expected: expecVec, actual: anArc.EndRadiusVector); Assertt.AreEqual( expected: new Point(100.0, 100.0), actual: anArc.Origin); Assert.AreEqual( expected: 50.0, actual: anArc.Radius, delta: 0.00001, message: "Radius"); Assert.AreEqual( expected: 0.0, actual: anArc.Rotation.getAsDegreesDouble(), delta: 0.00001, message: "Rotation"); Assert.AreEqual( expected: 50.0, actual: anArc.ScaleVector.Length, delta: 0.00001); }
public void Deflection_Left_divideBy2_isCorrect() { Deflection deflA = new Deflection(); deflA.setFromDegreesDouble(-4.0); Deflection defl = deflA / 2.0; Double expected = -2.0; Double actual = defl.getAsDegreesDouble(); Assert.AreEqual(expected: expected, actual: actual, delta: delta); }
public double GetShippingTime(Region reg) { reg.PackingTime = Deflection.Do(reg.PackingTime, reg.PackingTimeDeflection); var country = reg.Distance.ToList()[Deflection.rnd.Next(reg.Distance.Count)]; double shipping = Deflection.Do(country.Value / reg.ShippingSpeed, reg.ShippingTimeDeflection); Console.WriteLine("Gear Box details is shipping from " + country.Key); reg.UnpackingTime = Deflection.Do(reg.UnpackingTime, reg.PackingTimeDeflection); double shippingTime = reg.PackingTime + shipping + reg.UnpackingTime; PrintShippingTime(reg.PackingTime, shipping, reg.UnpackingTime); return(shippingTime); }
public Arc(Point centerPt, Point StartPt, Deflection defl) : this() { Origin = StartPt; Deflection = defl; CenterPt = centerPt; //this.Radius; BeginRadiusVector = Origin - CenterPt; //BeginPointAngle = Deflection / 2; //CentralVector = BeginRadiusVector + BeginPointAngle; EndRadiusVector = BeginRadiusVector + Deflection; EndPt = CenterPt + EndRadiusVector; computeBoundingBox(); }
public void Azimuth_1_30_addDeflection_Pos2_15_shouldYieldNewAzimuth_3_45() { Azimuth anAzimuth = new Azimuth(); anAzimuth.setFromDegreesMinutesSeconds(1, 30, 0); Deflection aDefl = new Deflection(); aDefl.setFromDegreesMinutesSeconds(2, 15, 0); Double expected = 3.75; Azimuth newAz = anAzimuth + aDefl; Double actual = newAz.getAsDegreesDouble(); Assert.AreEqual(expected: expected, actual: actual, delta: delta); }
public Arc(Point centerPt, Double incomingDir_, Double outgoingDir_, Double radius) { Azimuth incomingDir = Azimuth.ctorAzimuthFromDegree(incomingDir_); Azimuth outgoingDir = Azimuth.ctorAzimuthFromDegree(outgoingDir_); int modifier = (outgoingDir - incomingDir) > 0 ? 1 : -1; Azimuth BegRadiusDirection = incomingDir + new Deflection(Math.PI / 2.0, -1 * modifier); BeginRadiusVector = new Vector( direction: BegRadiusDirection, length: radius); Point startPt = centerPt + BeginRadiusVector; Deflection def = outgoingDir - incomingDir; populateThis(startPt, incomingDir, def, radius); }
public void setUpTestingModel_20140422() { setUpFeaturesForTestingModel(); allGrahics = new List <Graphic>(); this.AddGraphic(new LineSegment(1.0, 8.5, 13.2, 0.8)); this.AddGraphic(new LineSegment(1.0, 2.5, 13.2, 9.5)); this.AddGraphic(new LineSegment(0.0, 0.0, 0.5, 0.25)); this.AddGraphic(new LineSegment(2.0, 1.0, 1.0, 1.0)); this.AddGraphic(new LineSegment(0.0, 0.0, 1.5, 0.0)); this.AddGraphic(new LineSegment(0.1, 0.0, -1.3, -1.3)); this.AddGraphic(new LineSegment(0.1, 0.0, -1.3, -0.7)); this.AddGraphic(new LineSegment(0.1, 0.0, 1.0, -1.0)); this.AddGraphic(new LineSegment(0.1, 0.0, 1.3, -0.7)); this.AddGraphic(new LineSegment(0.1, 0.0, 1.6, -1.6)); this.AddGraphic(new Text("1.6, -0.6", new Point(1.6, -0.6), 0.25)); this.AddGraphic(new Text("-2, +0.9", new Point(-2, 0.9), 0.45)); var rotexPt = new Point(-1.1, -0.6); //var rotText = new Text("Rotated 1", rotexPt, 0.3); //rotText.Rotation = Angle.radiansFromDegree(1); //this.AddGraphic(rotText); //var rotText2 = new Text("Rotated 5", rotexPt, 0.3); //rotText2.Rotation = Angle.radiansFromDegree(5); //this.AddGraphic(rotText2); var rotText3 = new Text("Rotated 340", rotexPt, 0.3); rotText3.Rotation = Angle.radiansFromDegree(340); rotText3.Feature = this.FeatureList.Children["GreenDot"]; this.AddGraphic(rotText3); var anArc = new Arc(new Point(-1.4, 1.5), Azimuth.ctorAzimuthFromDegree(20.0), Deflection.ctorDeflectionFromAngle(310.0, 1), 0.25); anArc.Feature = this.FeatureList.Children["BlueDashed"]; this.AddGraphic(anArc); allGrahics[0].Feature = this.FeatureList.Children["GreenDot"]; allGrahics[1].Feature = this.FeatureList.Children["RedThick"]; allGrahics[2].Feature = this.FeatureList.Children["BlueDashed"]; }
public void Azimuth_Subtraction_Az340MinusAz268_equalsDeflectionPos72() { Azimuth incomingDir = Azimuth.ctorAzimuthFromDegree(268); var str = incomingDir.ToString(); Assert.AreEqual(268.0, incomingDir.getAsDegreesDouble(), 0.0000001); Azimuth outgoingDir = Azimuth.ctorAzimuthFromDegree(340); Assert.AreEqual(340.0, outgoingDir.getAsDegreesDouble(), 0.0000001); Deflection def = outgoingDir - incomingDir; Assert.AreEqual (expected: 72.0 , actual: def.getAsDegreesDouble() , delta: 0.00001); Assert.AreEqual (expected: 1 , actual: def.deflectionDirection); }
public Arc(Point StartPt, Azimuth incomingDir, Deflection defl, Double radius) : this() { populateThis(StartPt, incomingDir, defl, radius); }