コード例 #1
0
ファイル: Bounds2.cs プロジェクト: helgef/flysight
 public Bounds2(Bounds2 original)
 {
     this.minX = original.minX;
     this.minY = original.minY;
     this.maxX = original.maxX;
     this.maxY = original.maxY;
 }
コード例 #2
0
 public Bounds2(Bounds2 original)
 {
     this.minX = original.minX;
     this.minY = original.minY;
     this.maxX = original.maxX;
     this.maxY = original.maxY;
 }
コード例 #3
0
ファイル: Bounds2.cs プロジェクト: martin-holy/PeaksFromSrtm
        /// <summary>
        /// Returns the union of two <see cref="GeoBounds"/> objects.
        /// </summary>
        /// <param name="with"><see cref="GeoBounds"/> object to unite with.</param>
        /// <returns>Union of two <see cref="GeoBounds"/> objects.</returns>
        public Bounds2 Union(Bounds2 with)
        {
            if (with == null)
            {
                throw new ArgumentNullException("with");
            }

            return(new Bounds2(Math.Min(MinX, with.MinX), Math.Min(MinY, with.MinY),
                               Math.Max(MaxX, with.MaxX), Math.Max(MaxY, with.MaxY)));
        }
コード例 #4
0
ファイル: Bounds2.cs プロジェクト: martin-holy/PeaksFromSrtm
        /// <summary>
        /// Compares the current <see cref="Bounds2"/> object to the specified object for equivalence.
        /// </summary>
        /// <param name="obj">The <see cref="Bounds2"/> object to test for equivalence with the current object.</param>
        /// <returns>
        /// <c>true</c> if the two <see cref="Bounds2"/> objects are equal; otherwise, <c>false</c>.
        /// </returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            Bounds2 that = obj as Bounds2;

            if (that == null)
            {
                return(false);
            }

            return(minX.Equals(that.minX) && minY.Equals(that.minY) && maxX.Equals(that.maxX) && maxY.Equals(that.MaxY));
        }
コード例 #5
0
        private static int OutCodes(Bounds2 bounds, Point2 <double> P)
        {
            int Code = 0;

            if (P.Y > bounds.MaxY)
            {
                Code += 1;                    /* code for above */
            }
            else if (P.Y < bounds.MinY)
            {
                Code += 2;                         /* code for below */
            }
            if (P.X > bounds.MaxX)
            {
                Code += 4;                    /* code for right */
            }
            else if (P.X < bounds.MinX)
            {
                Code += 8;                         /* code for left */
            }
            return(Code);
        }
コード例 #6
0
ファイル: Bounds2.cs プロジェクト: martin-holy/PeaksFromSrtm
 /// <summary>
 /// Checks if the object intersects with specified boundaries.
 /// </summary>
 /// <param name="other">The other boundaries.</param>
 /// <returns>
 ///     <c>True</c> if it intersects, <c>false</c> otherwise.
 /// </returns>
 public bool IntersectsWith(Bounds2 other)
 {
     return(IntersectsWith(other.minX, other.minY, other.maxX, other.maxY));
 }
コード例 #7
0
ファイル: Bounds2.cs プロジェクト: helgef/flysight
        private static int OutCodes(Bounds2 bounds, Point2<double> P)
        {
            int Code = 0;

            if (P.Y > bounds.MaxY) Code += 1; /* code for above */
            else if (P.Y < bounds.MinY) Code += 2; /* code for below */

            if (P.X > bounds.MaxX) Code += 4; /* code for right */
            else if (P.X < bounds.MinX) Code += 8; /* code for left */

            return Code;
        }
コード例 #8
0
ファイル: Bounds2.cs プロジェクト: helgef/flysight
        public static void Clip(BoundsLineCrossing crossing, Bounds2 bounds)
        {
            int outCode0, outCode1;

            Point2<double> P0 = crossing.P0;
            Point2<double> P1 = crossing.P1;

            while (true)
            {
                outCode0 = OutCodes (bounds, P0);
                outCode1 = OutCodes (bounds, P1);

                crossing.P0 = P0;
                crossing.P1 = P1;

                if (RejectCheck (outCode0, outCode1))
                    return;

                if (AcceptCheck (outCode0, outCode1))
                    return;

                if (outCode0 == 0)
                {
                    double tempCoord; int tempCode;
                    tempCoord = P0.X; P0.X = P1.X; P1.X = tempCoord;
                    tempCoord = P0.Y; P0.Y = P1.Y; P1.Y = tempCoord;
                    tempCode = outCode0; outCode0 = outCode1; outCode1 = tempCode;
                    BoundsLineCrossingType tempType;
                    tempType = crossing.CrossingTypePoint0; crossing.CrossingTypePoint0 = crossing.CrossingTypePoint1; crossing.CrossingTypePoint1 = tempType;
                }

                if ((outCode0 & 1) != 0)
                {
                    P0.X += (P1.X - P0.X) * (bounds.MaxY - P0.Y) / (P1.Y - P0.Y);
                    P0.Y = bounds.MaxY;
                    crossing.CrossingTypePoint0 = BoundsLineCrossingType.CrossesMaxY;
                    crossing.HasCrossed = true;
                }
                else
                    if ((outCode0 & 2) != 0)
                    {
                        P0.X += (P1.X - P0.X) * (bounds.MinY - P0.Y) / (P1.Y - P0.Y);
                        P0.Y = bounds.MinY;
                        crossing.CrossingTypePoint0 = BoundsLineCrossingType.CrossesMinY;
                        crossing.HasCrossed = true;
                    }
                    else
                        if ((outCode0 & 4) != 0)
                        {
                            P0.Y += (P1.Y - P0.Y) * (bounds.MaxX - P0.X) / (P1.X - P0.X);
                            P0.X = bounds.MaxX;
                            crossing.CrossingTypePoint0 = BoundsLineCrossingType.CrossesMaxX;
                            crossing.HasCrossed = true;
                        }
                        else
                            if ((outCode0 & 8) != 0)
                            {
                                P0.Y += (P1.Y - P0.Y) * (bounds.MinX - P0.X) / (P1.X - P0.X);
                                P0.X = bounds.MinX;
                                crossing.CrossingTypePoint0 = BoundsLineCrossingType.CrossesMinX;
                                crossing.HasCrossed = true;
                            }
            }
        }
コード例 #9
0
ファイル: Bounds2.cs プロジェクト: helgef/flysight
        /// <summary>
        /// Returns the union of two <see cref="Bounds2"/> objects.
        /// </summary>
        /// <param name="with"><see cref="Bounds2"/> object to unite with.</param>
        /// <returns>Union of two <see cref="Bounds2"/> objects.</returns>
        public Bounds2 Union(Bounds2 with)
        {
            if (with == null)
                throw new ArgumentNullException ("with");

            return new Bounds2 (Math.Min (MinX, with.MinX), Math.Min (MinY, with.MinY),
                Math.Max (MaxX, with.MaxX), Math.Max (MaxY, with.MaxY));
        }
コード例 #10
0
ファイル: Bounds2.cs プロジェクト: helgef/flysight
 /// <summary>
 /// Checks if the object intersects with specified boundaries.
 /// </summary>
 /// <param name="other">The other boundaries.</param>
 /// <returns>
 /// 	<c>True</c> if it intersects, <c>false</c> otherwise.
 /// </returns>
 public bool IntersectsWith(Bounds2 other)
 {
     return IntersectsWith (other.minX, other.minY, other.maxX, other.maxY);
 }
コード例 #11
0
        static public void Clip(BoundsLineCrossing crossing, Bounds2 bounds)
        {
            int outCode0, outCode1;

            Point2 <double> P0 = crossing.P0;
            Point2 <double> P1 = crossing.P1;

            while (true)
            {
                outCode0 = OutCodes(bounds, P0);
                outCode1 = OutCodes(bounds, P1);

                crossing.P0 = P0;
                crossing.P1 = P1;

                if (RejectCheck(outCode0, outCode1))
                {
                    return;
                }

                if (AcceptCheck(outCode0, outCode1))
                {
                    return;
                }

                if (outCode0 == 0)
                {
                    double tempCoord; int tempCode;
                    tempCoord = P0.X; P0.X = P1.X; P1.X = tempCoord;
                    tempCoord = P0.Y; P0.Y = P1.Y; P1.Y = tempCoord;
                    tempCode  = outCode0; outCode0 = outCode1; outCode1 = tempCode;
                    BoundsLineCrossingType tempType;
                    tempType = crossing.CrossingTypePoint0; crossing.CrossingTypePoint0 = crossing.CrossingTypePoint1; crossing.CrossingTypePoint1 = tempType;
                }

                if ((outCode0 & 1) != 0)
                {
                    P0.X += (P1.X - P0.X) * (bounds.MaxY - P0.Y) / (P1.Y - P0.Y);
                    P0.Y  = bounds.MaxY;
                    crossing.CrossingTypePoint0 = BoundsLineCrossingType.CrossesMaxY;
                    crossing.HasCrossed         = true;
                }
                else
                if ((outCode0 & 2) != 0)
                {
                    P0.X += (P1.X - P0.X) * (bounds.MinY - P0.Y) / (P1.Y - P0.Y);
                    P0.Y  = bounds.MinY;
                    crossing.CrossingTypePoint0 = BoundsLineCrossingType.CrossesMinY;
                    crossing.HasCrossed         = true;
                }
                else
                if ((outCode0 & 4) != 0)
                {
                    P0.Y += (P1.Y - P0.Y) * (bounds.MaxX - P0.X) / (P1.X - P0.X);
                    P0.X  = bounds.MaxX;
                    crossing.CrossingTypePoint0 = BoundsLineCrossingType.CrossesMaxX;
                    crossing.HasCrossed         = true;
                }
                else
                if ((outCode0 & 8) != 0)
                {
                    P0.Y += (P1.Y - P0.Y) * (bounds.MinX - P0.X) / (P1.X - P0.X);
                    P0.X  = bounds.MinX;
                    crossing.CrossingTypePoint0 = BoundsLineCrossingType.CrossesMinX;
                    crossing.HasCrossed         = true;
                }
            }
        }