/// <summary>
            /// 線分と点pとの距離
            /// (一応、線分は有限長の線のこと)
            /// </summary>
            /// <param name="other"></param>
            /// <returns></returns>
            public double DistanceSP(Point p)
            {
                if (Point.Dot(P2 - P1, p - P1) < 0)
                {
                    return(Point.Abs(p - P1));
                }
                if (Point.Dot(P1 - P2, p - P2) < 0)
                {
                    return(Point.Abs(p - P2));
                }

                return(DistanceLP(p));
            }
Example #2
0
        public Map(Point size, T empty = default(T))
        {
            Size    = size.Abs();
            Empty   = empty;
            _region = new T[Columns, Rows];

            for (int i = 0; i < Area; i++)
            {
                var x = i % Columns;
                var y = i / Columns;
                _region[x, y] = Empty;
            }
        }
Example #3
0
        public static Texture[] Split(Texture2D xnaTexture, Point frameSize)
        {
            frameSize = frameSize.Abs();

            var columns = xnaTexture.Width / frameSize.X;
            var rows    = xnaTexture.Height / frameSize.Y;
            var frames  = new Texture[columns * rows];

            for (int i = 0; i < frames.Length; i++)
            {
                var position = new Point(i % columns, i / columns) * frameSize;
                frames[i] = new Texture(xnaTexture, position, frameSize);
            }

            return(frames);
        }
Example #4
0
        public void Abs()
        {
            var a = new Point(1, -2, 3);

            Point.Abs(a).Should().Be(new Point(1, 2, 3));
        }
 /// <summary>
 /// 直線と点pとの距離
 /// (一応、直線は無限長の線のこと)
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public double DistanceLP(Point p)
 {
     return(Math.Abs(Point.Cross(Diffrent(), p - P1) / Point.Abs(Diffrent())));
 }
Example #6
0
 public void Resize(Point size)
 {
     Resize(Point.Zero, size.Abs());
 }
Example #7
0
 protected TileMapCollider(Vector2 position, Point mapSize, Point tileSize)
     : base(position)
 {
     Map       = new Map <int>(mapSize);
     _tileSize = tileSize.Abs();
 }