public static void Rotate(this IEnumerable<PlaneRegion> passedPlaneRegions, Line passedAxisLine, Angle passedRotationAngle)
 {
     foreach (var planeRegion in passedPlaneRegions)
     {
         planeRegion.Rotate(passedAxisLine, passedRotationAngle);
     }
 }
        private static Dictionary<Cluster, Cluster> FindNearestNeighbors(List<Cluster> c1l, List<Cluster> c2l, out List<Angle> angles, Angle angleBase, Angle angleTolerance)
        {
            Dictionary<Cluster, Cluster> neighbors = new Dictionary<Cluster, Cluster>();
            angles = new List<Angle>();
            foreach (Cluster c1 in c1l)
            {
                float shortestDistance = 999999;
                Cluster shortestCluster = null;

                foreach (Cluster c2 in c2l)
                {
                    if (new Angle(Math.Abs((c1.GetAngle(c2) - angleBase).angleDegrees)).angleDegrees > angleTolerance.angleDegrees)
                        continue;
                    //if (Math.Abs(Cluster.CompareAngles(c1.GetAngle(c2), angleBase)) > angleTolerance.angleDegrees)

                    float currentDistance = c1.Distance(c2);
                    if (currentDistance < shortestDistance)
                    {
                        shortestCluster = c2;
                        shortestDistance = currentDistance;
                    }
                    if (shortestDistance == 0)
                    {
                    }
                }
                if (shortestCluster != null)
                {
                    neighbors.Add(c1, shortestCluster);
                    angles.Add(c1.GetAngle(shortestCluster));
                }
            }
            return neighbors;
        }
Esempio n. 3
0
 public PolarCoordinate(float r, double theta, Azimuth origin, PolarCoordinateOrientation orientation)
 {
     _R = r;
     _Theta = new Angle(theta);
     _Origin = origin;
     _Orientation = orientation;
 }
Esempio n. 4
0
        private void Button_Click1(object sender, RoutedEventArgs e)
        {
            int aangle, bangle;

            Csubbox.Text = "";

            aangle = Convert.ToInt32(Asubbox.Text);
            bangle = Convert.ToInt32(Bsubbox.Text);

            if (aangle < 0 || aangle > 360 || bangle < 0 || bangle > 360)
            {
                MessageBox.Show("Углы должны быть в диапазоне от 0 до 360 градусов");
                return;
            }

            Angle A = new Angle();
            Angle B = new Angle();

            A.deg = aangle;
            B.deg = bangle;

            double res;

            res = A.Sub(B);

            Csubbox.Text = res.ToString();
        }
Esempio n. 5
0
 /// <summary>
 /// Creates a new Arc
 /// </summary>
 /// <param name="radius">The radius of the arc</param>
 /// <param name="angle">The arc angle</param>
 /// <param name="baseVector">A vector of the arc start</param>
 public Arc(double? radius, Angle? angle, Vector2 baseVector)
 {
     _angle = angle;
     _radius = radius;
     _base = baseVector;
     _bowlen = null;
 }
        //////////////////////////////////////////////////////////////////////////////////////
        // This method takes in present position (LatLongClass) and range/bearing from the
        // present position. It returns a new position (LatLongClass)
        //
        // Distance is IN
        // Azimuth in degrees
        public static LatLongClass CalculateNewPosition(LatLongClass PresentPosition, double Distance, double Azimuth)
        {
            LatLongClass NewPosition = new LatLongClass();

            // instantiate the calculator
            GeodeticCalculator geoCalc = new GeodeticCalculator();

            // select a reference elllipsoid
            Ellipsoid reference = Ellipsoid.WGS84;

            // set Lincoln Memorial coordinates
            GlobalCoordinates Present_Pos;
            Present_Pos = new GlobalCoordinates(new Angle(PresentPosition.GetLatLongDecimal().LatitudeDecimal), new Angle(PresentPosition.GetLatLongDecimal().LongitudeDecimal));

            // now, plug the result into to direct solution
            GlobalCoordinates dest;
            Angle endBearing = new Angle();

            double Distance_In_Meeters = (Distance * NMtoKM * 1000.0);

            dest = geoCalc.CalculateEndingGlobalCoordinates(reference, Present_Pos, Azimuth, Distance_In_Meeters, out endBearing);
            NewPosition.SetPosition(new LatLongDecimal(dest.Latitude.Degrees, dest.Longitude.Degrees));

            return NewPosition;
        }
Esempio n. 7
0
        internal void SetType(ParticleType type)
        {
            Type = type;

            Scale = Type.ScaleModifier.Random;
            Angle = Type.AngleModifier.Random;
            Alpha = Type.AlphaModifier.Random;

            LifeMax = (int)Math.Round(Type.realLife.Random);
            Life = 0;
            LifePercent = 0;

            if (Type.Mode == ParticleType.FrameMode.Random)
                Frame = (int)Calc.Random.Next(Type.Sprite.Length);
            else
                Frame = 0;

            if (Type.BlendWithTime)
                Color = Type.Blend[0];
            else
                Color = Calc.Random.Choose(Type.Blend);

            Velocity = new Angle(Type.Direction.Random, true).ToVector(Type.Speed.Random);

            DrawScale = new Vector2(Type.ScaleX.Min, Type.ScaleY.Min) * Type.Size.Min * Scale;
            DrawAngle = new Angle(Type.Angle.Min + Angle, true);
        }
Esempio n. 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.QuadTile"/> class.
        /// </summary>
        /// <param name="south"></param>
        /// <param name="north"></param>
        /// <param name="west"></param>
        /// <param name="east"></param>
        /// <param name="level"></param>
        /// <param name="quadTileSet"></param>
        public QuadTile(double south, double north, double west, double east, int level, QuadTileSet quadTileSet)
        {
            this.South = south;
            this.North = north;
            this.West = west;
            this.East = east;
            CenterLatitude = Angle.FromDegrees(0.5f*(North + South));
            CenterLongitude = Angle.FromDegrees(0.5f*(West + East));
            LatitudeSpan = Math.Abs(North - South);
            LongitudeSpan = Math.Abs(East - West);

            this.Level = level;
            this.QuadTileSet = quadTileSet;

            BoundingBox = new BoundingBox((float) south, (float) north, (float) west, (float) east, (float) quadTileSet.LayerRadius, (float) quadTileSet.LayerRadius + 300000f);
            //localOrigin = BoundingBox.CalculateCenter();
            localOrigin = MathEngine.SphericalToCartesianD(CenterLatitude, CenterLongitude, quadTileSet.LayerRadius);

            // To avoid gaps between neighbouring tiles truncate the origin to
            // a number that doesn't get rounded. (nearest 10km)
            localOrigin.X = (float) (Math.Round(localOrigin.X/10000)*10000);
            localOrigin.Y = (float) (Math.Round(localOrigin.Y/10000)*10000);
            localOrigin.Z = (float) (Math.Round(localOrigin.Z/10000)*10000);

            Row = MathEngine.GetRowFromLatitude(South, North - South);
            Col = MathEngine.GetColFromLongitude(West, North - South);
        }
Esempio n. 9
0
	/// <summary>
	/// Calculate the destination if we start at:
	///    Lincoln Memorial in Washington, D.C --> 38.8892N, 77.04978W
	///         and travel at
	///    51.7679 degrees for 6179.016136 kilometers
	/// 
	///    WGS84 reference ellipsoid
	/// </summary>
	static void TwoDimensionalDirectCalculation()
	{
	  // instantiate the calculator
	  GeodeticCalculator geoCalc = new GeodeticCalculator();

	  // select a reference elllipsoid
	  Ellipsoid reference = Ellipsoid.WGS84;

	  // set Lincoln Memorial coordinates
	  GlobalCoordinates lincolnMemorial;
	  lincolnMemorial = new GlobalCoordinates(
		  new Angle(38.88922), new Angle(-77.04978)
	  );

	  // set the direction and distance
	  Angle startBearing = new Angle(51.7679);
	  double distance = 6179016.13586;

	  // find the destination
	  Angle endBearing;
	  GlobalCoordinates dest = geoCalc.CalculateEndingGlobalCoordinates(reference, lincolnMemorial, startBearing, distance, out endBearing);

	  Console.WriteLine("Travel from Lincoln Memorial at 51.767921 deg for 6179.016 km");
	  Console.Write("   Destination: {0:0.0000}{1}", dest.Latitude.Degrees, (dest.Latitude > 0) ? "N" : "S" );
	  Console.WriteLine(", {0:0.0000}{1}", dest.Longitude.Degrees, (dest.Longitude > 0) ? "E" : "W");
	  Console.WriteLine("   End Bearing: {0:0.00} degrees", endBearing.Degrees);
	}
Esempio n. 10
0
 public void TestRotateAroundOrigin()
 {
     Angle a = new Angle(90, Angle.Representation.Degree);
     Point p1 = new Point(2.5, 0.0);
     var rotated = Rotation.AroundOrigin(a, p1);
     Assert.AreEqual(0.0, rotated.X, 0.01);
     Assert.AreEqual(2.5, rotated.Y, 0.01);
 }
Esempio n. 11
0
        /// <summary>
        /// Returns a point on this circle at the given angle offset.
        /// </summary>
        /// <param name="angle"></param>
        /// <returns></returns>
        public Vector2 GetPoint(Angle angle){
            var circlePoint = new Vector2(
                Math.Cos(angle.Radians) * this.Radius,
                Math.Sin(angle.Radians) * this.Radius);

            circlePoint += this.Location;
            return circlePoint;
        }
Esempio n. 12
0
    public void ConvertDegreesMinutesSeconds()
    {
      Angle angle = new Angle(10, 30, 20);
      Assert.IsTrue(TestingUtils.AreEqualWithinTolerance(angle.Degrees, 10.505555556));

      angle = new Angle(-10, 30, 20);
      Assert.IsTrue(TestingUtils.AreEqualWithinTolerance(angle.Degrees, 10.505555556));
    }
		public void Rotate_100x0yPlus45_71x71y()
		{
			var velocity = new Velocity(10, 0);
			var angle = new Angle(Math.PI / 4d);
			var act = velocity.Rotate(angle);
			var exp = new Velocity(Math.Sqrt(50), Math.Sqrt(50));

			CloudBallAssert.AreEqual(exp, act);
		}
Esempio n. 14
0
 public void TestRotateAroundPoint()
 {
     Angle a = new Angle(45, Angle.Representation.Degree);
     Point c1 = new Point(0.5, 0.5);
     Point p1 = new Point(1, 2);
     var rotated = Rotation.AroundPoint(c1, a, p1);
     Assert.AreEqual(-0.2071, rotated.X, 0.01);
     Assert.AreEqual(1.9142, rotated.Y, 0.01);
 }
Esempio n. 15
0
 // Prevent null reference access
 /// <summary>Initializes a new instance of the Latitude class.</summary>
 /// <param name="angle">The angle of the latitude.</param>
 /// <exception cref="ArgumentNullException">angle is null.</exception>
 /// <exception cref="ArgumentOutOfRangeException">
 /// angle is greater than 90 degrees or less than -90 degrees.
 /// </exception>
 public Latitude(Angle angle)
     : base((angle ?? new Angle(0)).Radians)
 {
     if (angle == null)
     {
         throw new ArgumentNullException("angle");
     }
     ValidateRange("angle", angle.Radians, -Math.PI / 2.0, Math.PI / 2.0);
 }
Esempio n. 16
0
        public void HemisphereAngleConstructorTest1()
        {
            Angle angle = new Angle(0);

            Latitude latitude = new Latitude(angle,CardinalDirection.South);

            Assert.AreEqual(angle, latitude.Value);
            Assert.AreEqual(angle, latitude.RawValue);
        }
Esempio n. 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref= "T:WorldWind.Camera.WorldCamera"/> class.
 /// </summary>
 /// <param name="targetPosition"></param>
 /// <param name="radius"></param>
 public WorldCamera(Vector3 targetPosition, double radius)
     : base(radius)
 {
     this._targetOrientation = m_Orientation;
     this._targetDistance = this._distance;
     this._targetAltitude = this._altitude;
     this._targetTilt = this._tilt;
     this._targetFov = this._fov;
 }
		public void Rotate_Minus135_71x71y()
		{
			var velocity = new Velocity(10, 0);
			var angle = new Angle(-3 * Math.PI / 4d);
			var act = velocity.Rotate(angle);
			var exp = new Velocity(-Math.Sqrt(50), -Math.Sqrt(50));

			CloudBallAssert.AreEqual(exp, act);
		}
Esempio n. 19
0
 // Prevent null reference access
 public SailAngle(Angle angle)
     : base((angle ?? new Angle(0)).Radians)
 {
     if (angle == null)
     {
         throw new ArgumentNullException("angle");
     }
     ValidateRange("SailAngle", angle.TotalDegrees, 0, 90);
 }
Esempio n. 20
0
 // Prevent null reference access, we'll validate later
 /// <summary>Initializes a new instance of the Longitude class.</summary>
 /// <param name="angle">The angle of the longitude.</param>
 /// <exception cref="ArgumentNullException">angle is null.</exception>
 /// <exception cref="ArgumentOutOfRangeException">
 /// angle is greater than 180 degrees or less than -180 degrees.
 /// </exception>
 public Longitude(Angle angle)
     : this((angle ?? new Angle(0)).Radians)
 {
     if (angle == null)
     {
         throw new ArgumentNullException("angle");
     }
     ValidateRange("angle", angle.Radians, -Math.PI, Math.PI);
 }
Esempio n. 21
0
        public void TestSin()
        {
            Angle a = new Angle(90, Angle.Representation.Degree);
            double sin90 = Trigonometry.Sin(a);
            Assert.AreEqual(1, sin90, 0.01);

            Angle b = new Angle(0.5); // radians
            double sin05rad = Trigonometry.Sin(b);
            Assert.AreEqual(0.47942, sin05rad, 0.01);
        }
        public void Stern()
        {
            Angle heading = new Angle(new Vector(-1, 0));

            Vector relativePosition = new Vector(1, 0);

            var facing = heading.ToFacing(relativePosition);

            Assert.AreEqual(Facing.Stern, facing);
        }
        public void Starboard()
        {
            Angle heading = new Angle(new Vector(1, 0));

            Vector relativePosition = new Vector(0, -1);

            var facing = heading.ToFacing(relativePosition);

            Assert.AreEqual(Facing.Starboard, facing);
        }
        public void Port()
        {
            Angle heading = new Angle(new Vector(-1, 0));

            Vector relativePosition = new Vector(0, -1);

            var facing = heading.ToFacing(relativePosition);

            Assert.AreEqual(Facing.Port, facing);
        }
        public void BowIsBow()
        {
            Angle heading = new Angle(new Vector(0, 1));

            Vector relativePosition = new Vector(0, 1);

            var facing = heading.ToFacing(relativePosition);

            Assert.AreEqual(Facing.Bow, facing);
        }
Esempio n. 26
0
        public void DecimalConstructorTest3()
        {
            Angle angle = new Angle(33.5);

            Assert.AreEqual(33, angle.Degrees);
            Assert.AreEqual(30, angle.Minutes);
            Assert.AreEqual(30.0, angle.DecimalMinutes);
            Assert.AreEqual(0.0, angle.Seconds);
            Assert.AreEqual(33.5, angle.DecimalDegrees);
        }
Esempio n. 27
0
        public void DecimalConstructorTest4()
        {
            Angle angle = new Angle(13.12345);

            Assert.AreEqual(13, angle.Degrees);
            Assert.AreEqual(7, angle.Minutes);
            Assert.AreEqual(7.407, angle.DecimalMinutes);
            Assert.AreEqual(24.42, angle.Seconds);
            Assert.AreEqual(13.12345, angle.DecimalDegrees);
        }
Esempio n. 28
0
		public GumpItemShadow(int x, int y, int itemID, int itemHue, Angle shadowAngle, int shadowOffset, int shadowHue)
		{
			_X = x;
			_Y = y;
			_ItemID = itemID;
			_ItemHue = itemHue;
			_ShadowAngle = shadowAngle;
			_ShadowOffset = shadowOffset;
			_ShadowHue = shadowHue;
		}
Esempio n. 29
0
		public GumpImageShadow(int x, int y, int imageID, int imageHue, Angle shadowAngle, int shadowOffset, int shadowHue)
		{
			_X = x;
			_Y = y;
			_ImageID = imageID;
			_ImageHue = imageHue;
			_ShadowAngle = shadowAngle;
			_ShadowOffset = shadowOffset;
			_ShadowHue = shadowHue;
		}
Esempio n. 30
0
        public void DecimalConstructorTest2()
        {
            Angle angle = new Angle(12.25);

            Assert.AreEqual(12, angle.Degrees);
            Assert.AreEqual(15, angle.Minutes);
            Assert.AreEqual(15.0, angle.DecimalMinutes);
            Assert.AreEqual(0.0, angle.Seconds);
            Assert.AreEqual(12.25, angle.DecimalDegrees);
        }