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(); }
public void Vector_newVector_isCorrect() { var az = Azimuth.ctorAzimuthFromDegree(90.0); var aVec = new Vector(az, 50.0); Assert.IsNotNull(aVec); Assert.AreEqual(expected: 50.0, actual: aVec.x, delta: 0.00001); }
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 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 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); }