예제 #1
0
파일: Vector.cs 프로젝트: catashd/NetVecCad
 public Vector(Azimuth direction, Double length)
     : this()
 {
     x = length * Math.Sin(direction.getAsRadians());
      y = length * Math.Cos(direction.getAsRadians());
      z = null;
 }
예제 #2
0
        public Deflection(Azimuth BeginAzimuth, Azimuth EndAzimuth, bool assumeInternalSolution)
        {
            Double angle;

             // first assume internal solution
             if(BeginAzimuth.angle_ > EndAzimuth.angle_)
             {
            if ((BeginAzimuth.angle_ - EndAzimuth.angle_) > 180.0)
            {
               angle = (EndAzimuth.angle_ + 360.0) - BeginAzimuth.angle_;
            }
            else
            {
               angle = EndAzimuth.angle_ - BeginAzimuth.angle_;
            }
             }
             else // EndAzimuth >= BeginAzimuth
             {
            if ((EndAzimuth.angle_ - BeginAzimuth.angle_) > 180.0)
            {
               angle = (EndAzimuth.angle_ - BeginAzimuth.angle_) - 360.0;
            }
            else
            {
               angle = BeginAzimuth.angle_ - EndAzimuth.angle_;
            }
             }

             this.angle_ = angle.ToRadians();
             if (false == assumeInternalSolution)
            this.ForceToExternalSolution();
        }
예제 #3
0
 public static Azimuth operator -(Azimuth Az1, Deflection defl)
 {
     var newAzDeg = Az1.getAsDegreesDouble() - defl.getAsDegreesDouble();
      Double retDbl = Angle.normalizeToPlusOrMinus360Static(newAzDeg);
      Azimuth retAz = new Azimuth();
      retAz.setFromDegreesDouble(retDbl);
      return retAz;
 }
예제 #4
0
 public static Azimuth operator +(Azimuth Az1, Deflection defl)
 {
     var Az1Dbl = Az1.angle__;
      var deflDbl = defl.getAsRadians();
      var newAzDeg = Az1Dbl + deflDbl;
      if (newAzDeg > TwoPI()) newAzDeg -= TwoPI();
      if (newAzDeg < 0.0) newAzDeg += TwoPI();
      Azimuth retAz = new Azimuth(newAzDeg);
      return retAz;
 }
예제 #5
0
        public static Azimuth CreateFromCadConventionAngle(Angle angle)
        {
            Azimuth retVal;

            if (angle.angle_ <= PIover2)
            {
                retVal = new Azimuth(PIover2 - angle.angle_);
            }
            else
            {
                retVal = new Azimuth(PIover2 * 5 - angle.angle_);
            }
            return(retVal);
        }
예제 #6
0
        public static Azimuth operator +(Azimuth Az1, Deflection defl)
        {
            var Az1Dbl   = Az1.angle__;
            var deflDbl  = defl.getAsRadians();
            var newAzDeg = Az1Dbl + deflDbl;

            if (newAzDeg > TwoPI())
            {
                newAzDeg -= TwoPI();
            }
            if (newAzDeg < 0.0)
            {
                newAzDeg += TwoPI();
            }
            Azimuth retAz = new Azimuth(newAzDeg);

            return(retAz);
        }
예제 #7
0
 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);
 }
예제 #8
0
        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);
        }
예제 #9
0
파일: Arc.cs 프로젝트: catashd/NetVecCad
 public Arc(Point StartPt, Azimuth incomingDir, Deflection defl,
  Double radius)
     : this()
 {
     populateThis(StartPt, incomingDir, defl, radius);
 }
예제 #10
0
 //to do:
 //setAsAzimuth
 //getAsDegreeMinuteSecond
 //setAsDegree
 //setAsDegreeMinuteSecond
 //yada
 public static Azimuth ctorAzimuthFromDegree(Double deg)
 {
     Azimuth retAz = new Azimuth();
      retAz.setFromDegreesDouble(deg);
      return retAz;
 }
예제 #11
0
 public void Azimuth_setToDMS183__29__29_5_shouldResultIn_Angle()
 {
     Azimuth anAzimuth = new Azimuth();
      anAzimuth.setFromDegreesMinutesSeconds(183, 29, 29.5);
      Double expected = 183.4915277778;
      Double actual = anAzimuth.getAsDegreesDouble();
      Assert.AreEqual(expected: expected, actual: actual, delta: delta);
 }
예제 #12
0
 public static Azimuth CreateFromCadConventionAngle(Angle angle)
 {
     Azimuth retVal;
      if (angle.angle_ <= PIover2)
     retVal = new Azimuth(PIover2 - angle.angle_);
      else
     retVal = new Azimuth(PIover2 * 5 - angle.angle_);
      return retVal;
 }
예제 #13
0
        /// <summary>
        /// Always assumes that the desired answer is the internal solution.
        /// If the external solution is desired, 
        /// call deflection.ForceToExternalSolution()
        /// immediately after calling minus().
        /// </summary>
        /// <param name="Az2"></param>
        /// <returns></returns>
        public Deflection minus(Azimuth Az2)
        {
            Deflection returnDeflection =
            new Deflection(this, Az2, true);

             return returnDeflection;
        }
예제 #14
0
 public static Azimuth NewFromDoubleAsDegrees(Double az)
 {
     Azimuth returnAz = new Azimuth();
      returnAz.setFromDegreesDouble(az);
      return returnAz;
 }
예제 #15
0
        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);
             }
        }
예제 #16
0
        public void Azimuth_setFromXY()
        {
            Tuple<Double, Double, Double>[] testCases =  {
            new Tuple<Double, Double, Double>(10, 2, 78.690067526),
            new Tuple<Double, Double, Double>(10, -2, 101.309932474),
            new Tuple<Double, Double, Double>(-10, 2, 281.309932474),
            new Tuple<Double, Double, Double>(-10, -2, 258.690067526) };

             foreach(var testCase in testCases)
             {
            Azimuth anAzimuth = new Azimuth();
            anAzimuth.setFromXY(testCase.Item1, testCase.Item2);
            Double actualDegrees = anAzimuth.getAsDegreesDouble();

            Assert.AreEqual(expected: testCase.Item3, actual: actualDegrees, delta: delta);
             }
        }
예제 #17
0
파일: Arc.cs 프로젝트: catashd/NetVecCad
        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();
        }
예제 #18
0
 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);
 }
예제 #19
0
 public static Azimuth ctorAzimuthFromAngle(Angle angle)
 {
     Azimuth retAz = new Azimuth();
      retAz.setFromDegreesDouble(angle.getAsDegreesDouble());
      return retAz;
 }