Ejemplo n.º 1
0
        public Box2D(IPoint2D <T> point, IVector2D <T> vector)
            : this()
        {
            dynamic startWidth = point.X;
            dynamic endWidth   = startWidth + vector.DeltaX;

            if (startWidth <= endWidth)
            {
                Width = new Interval <T>(startWidth, true, endWidth, true);
            }
            else
            {
                Width = new Interval <T>(endWidth, true, startWidth, true);
            }

            dynamic startHeight = point.Y;
            dynamic endHeight   = startHeight + vector.DeltaY;

            if (startHeight <= endHeight)
            {
                Height = new Interval <T>(startHeight, true, endHeight, true);
            }
            else
            {
                Height = new Interval <T>(endHeight, true, startHeight, true);
            }
        }
Ejemplo n.º 2
0
        public bool CollidesWith(IVector2D movement, Rectangle rectangle)
        {
            IVector2D envelopeOrigin = Origin.Add(movement);
            var envelope = new Rectangle(envelopeOrigin, Size);
            envelope = envelope.EnlargeRectangleRectangle(this);

            if (envelope.CollidesWith(rectangle))
            {
                float min = Size.X.Minimum(Size.Y) / 4.0f;
                float minimumMoveDistance = min.Maximum(Helper.Epsilon);

                if (movement.Length() < minimumMoveDistance)
                {
                    return true;
                }

                IVector2D halfMovement = movement.Divide(2.0f);

                envelope = new Rectangle(Origin.Add(halfMovement), Size);

                return CollidesWith(halfMovement, rectangle) ||
                       envelope.CollidesWith(halfMovement, rectangle);
            }

            return false;
        }
Ejemplo n.º 3
0
        public bool CollidesWith(IVector2D movement, Rectangle rectangle)
        {
            IVector2D halfMovement = movement.Divide(2.0f);
            float movementDistance = movement.Length();
            IVector2D envelopeCenter = Center.Add(halfMovement);
            float envelopeRadius = Radius + movementDistance / 2.0f;
            var envelope = new Circle(envelopeCenter, envelopeRadius);

            if (envelope.CollidesWith(rectangle))
            {
                float minimumMoveDistance = (Radius / 4.0f).Maximum(Helper.Epsilon);

                if (movementDistance < minimumMoveDistance)
                {
                    return true;
                }

                envelope = new Circle(envelope.Center, Radius);

                return CollidesWith(halfMovement, rectangle) ||
                       envelope.CollidesWith(halfMovement, rectangle);
            }

            return false;
        }
Ejemplo n.º 4
0
 public static bool PositionIsOutOfBounds <T>(IVector2D <int> position, IGrid <T> contextGrid)
 {
     return(PositionIsOutOfBoundsLeft(position.X) ||
            PositionIsOutOfBoundsRight(position.X, contextGrid) ||
            PositionIsOutOfBoundsUp(position.Y, contextGrid) ||
            PositionIsOutOfBoundsDown(position.Y));
 }
Ejemplo n.º 5
0
 public OrientedRectangle(IVector2D center, IVector2D halfExtend, float rotation)
     : this()
 {
     Center = center;
     HalfExtend = halfExtend;
     Rotation = rotation;
 }
Ejemplo n.º 6
0
        public static bool IsEquals(Vector v1, Vector v2) => v1.X == v2.X && v1.Y == v2.Y; //without boxing

        /// <summary>
        /// Vectors collinearity check
        /// </summary>
        /// <param name="v1"></param>
        /// <param name="v2"></param>
        /// <returns></returns>
        public static bool IsCollinear(IVector2D <double> v1, IVector2D <double> v2)
        {
            if ((v1.X == 0 && v2.X == 0) || (v1.Y == 0 && v2.Y == 0))
            {
                return(true);
            }
            return(v1.X / v2.X == v1.Y / v2.Y);
        }
Ejemplo n.º 7
0
        public bool IsParallel(IVector2D v)
        {
            IVector2D na = Rotate90();

            float dp = na.DotProduct(v);

            return dp.ApproximatelyEquals(0.0f);
        }
Ejemplo n.º 8
0
 public void SetCellAt(IVector2D <int> position, T obj)
 {
     if (PositionIsOutOfBounds(position))
     {
         throw new IndexOutOfRangeException("The given position is outside of grid boundaries.");
     }
     Cells[position.X, position.Y] = obj;
 }
Ejemplo n.º 9
0
 public T GetCellAt(IVector2D <int> position)
 {
     if (PositionIsOutOfBounds(position))
     {
         throw new IndexOutOfRangeException("The given position is outside of grid boundaries.");
     }
     return(Cells[position.X, position.Y]);
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Compares two vectors for equality.
        /// </summary>
        /// <param name="IVector">A vector to compare with.</param>
        /// <returns>True if both match; False otherwise.</returns>
        public Boolean Equals(IVector2D <T> IVector)
        {
            if ((Object)IVector == null)
            {
                return(false);
            }

            return(this.X.Equals(IVector.X) &&
                   this.Y.Equals(IVector.Y));
        }
Ejemplo n.º 11
0
        public float AngleBetween(IVector2D v)
        {
            IVector2D u1 = UnitVector();
            IVector2D u2 = v.UnitVector();

            float dp = u1.DotProduct(u2);

            var f = (float)Math.Acos(dp);

            return f.ToDegrees();
        }
Ejemplo n.º 12
0
        public IVector2D Clamp(IVector2D p)
        {
            var rangeX = new Range(Origin.X, Origin.X + Size.X);
            var rangeY = new Range(Origin.Y, Origin.Y + Size.Y);
            float x = rangeX.Clamp(p.X);
            float y = rangeY.Clamp(p.Y);

            IVector2D clamp = VectorFactory.GetVector2D(x, y);

            return clamp;
        }
Ejemplo n.º 13
0
        public void VerificarColisiones_NoColisiona2_RetornaFalse()
        {
            //Arrange
            r1 = new Personaje(5, 5);
            r2 = new Personaje(1, 1);

            //Act
            bool resultado = ColisionManager.ColisionaEnemigoPersonaje(r1, r2);

            //Assert
            Assert.IsFalse(resultado);
        }
Ejemplo n.º 14
0
        public void VerificarColisiones_CasoColisionaPorCompleto_RetornaTrue()
        {
            //Arrange
            r1 = new Personaje(300, 300);
            r2 = new Personaje(300, 300);

            //Act
            bool resultado = ColisionManager.ColisionaEnemigoPersonaje(r1, r2);

            //Assert
            Assert.IsTrue(resultado);
        }
Ejemplo n.º 15
0
        public void VerificarColisiones_Colisiona3_RetornaTrue()
        {
            //Arrange
            r1 = new Personaje(5, 5);
            r2 = new Personaje(7, 7);

            //Act
            bool resultado = ColisionManager.ColisionaEnemigoPersonaje(r1, r2);

            //Assert
            Assert.IsTrue(resultado);
        }
Ejemplo n.º 16
0
        public ShipPlacementResult PlaceShip(IShip ship, IVector2D <int> position, Direction direction, IGrid <ITile> grid)
        {
            //Check if one end of the ship if out of bounds.
            if (grid.PositionIsOutOfBounds(position))
            {
                return(ShipPlacementResult.ShipWasNotPlaced);
            }

            //Check if the other end of the ship if out of bounds.
            IVector2D <int> shipVector       = direction.ToIntVector(ship.Size);
            IVector2D <int> shipVectorOffset = position.Clone().Add(shipVector);

            if (grid.PositionIsOutOfBounds(shipVectorOffset))
            {
                return(ShipPlacementResult.ShipWasNotPlaced);
            }

            //List of tiles that the ship is going to occupy.
            List <ITile>    checkedTiles     = new List <ITile>();
            IVector2D <int> shipNormalVector = direction.ToIntVector();

            //Check if any tile along the given direction in the magnitude of the ships length is occupied.
            for (int i = 0; i < ship.Size; i++)
            {
                IVector2D <int> interpolatedShipVector = shipNormalVector.Clone().Mul(i);
                IVector2D <int> tilePosition           = position.Clone();
                tilePosition.Add(interpolatedShipVector);

                if (grid.PositionIsOutOfBounds(tilePosition))
                {
                    return(ShipPlacementResult.ShipWasNotPlaced);
                }
                ITile tile = grid.GetCellAt(tilePosition);

                //If any tile in the magnitude of the ship is occupied then cancel placement.
                if (tile.IsOccupied)
                {
                    return(ShipPlacementResult.ShipWasNotPlaced);
                }

                //Add tile for later assignment.
                checkedTiles.Add(tile);
            }

            foreach (ITile tile in checkedTiles)
            {
                tile.Occupant = ship;
            }

            //Ship placement was successful.
            return(ShipPlacementResult.ShipWasPlaced);
        }
Ejemplo n.º 17
0
        private void HandlePlacementPhaseTileClick(IVector2D <int> tilePosition)
        {
            IShip ship = CurrentPlayer.ShipsToBePlaced[0];

            //Attempt to place the ship
            var placementResult = PlaceShip(ship, tilePosition, Direction.East, CurrentPlayer.SecretGrid);

            if (placementResult == ShipPlacementResult.ShipWasPlaced)
            {
                CurrentPlayer.ShipsToBePlaced.Remove(ship);
                DecidePhaseAfterPlacement();
            }
        }
Ejemplo n.º 18
0
 //Corresponde que este metodo sea privado, lo dejo publico solo para poder correr los tests.
 private static bool VerificarColisionEnY(IVector2D v1, IVector2D v2)
 {
     if ((v1.LimiteTop < v2.LimiteTop && v1.LimiteBot > v2.LimiteBot) ||
         (v2.LimiteTop < v1.LimiteTop && v2.LimiteBot > v1.LimiteBot) ||
         (v1.Y == v2.Y))
     {
         return(true); //Colisiona por completo
     }
     if ((v1.Y < v2.Y && v1.LimiteTop > v2.LimiteBot) ||
         (v2.Y < v1.Y && v2.LimiteTop > v1.LimiteBot))
     {
         return(true); //Colision parcial
     }
     return(false);
 }
Ejemplo n.º 19
0
 //Corresponde que este metodo sea privado, lo dejo publico solo para poder correr los tests.
 private static bool VerificarColisionEnX(IVector2D v1, IVector2D v2)
 {
     if ((v1.LimiteDerecha < v2.LimiteDerecha && v1.LimiteIzquierda > v2.LimiteIzquierda) ||
         (v2.LimiteDerecha < v1.LimiteDerecha && v2.LimiteIzquierda > v1.LimiteIzquierda) ||
         (v1.X == v2.X))
     {
         return(true); //Colisiona por completo
     }
     if ((v1.X < v2.X && v1.LimiteDerecha > v2.LimiteIzquierda) ||
         (v2.X < v1.X && v2.LimiteDerecha > v1.LimiteIzquierda))
     {
         return(true); //Colision parcial
     }
     return(false);
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Determines if the given vector is parallel or
        /// antiparallel to this vector.
        /// </summary>
        /// <param name="Vector">A vector.</param>
        public Boolean IsParallelTo(IVector2D <T> Vector)
        {
            var ThisNormVector = this.NormVector;
            var ThatNormVector = Vector.NormVector;

            if ((ThisNormVector.X.Equals(ThatNormVector.X) &&
                 ThisNormVector.Y.Equals(ThatNormVector.Y)) ||
                (ThisNormVector.X.Equals(Math.Inv(ThatNormVector.X)) &&
                 ThisNormVector.Y.Equals(Math.Inv(ThatNormVector.Y))))
            {
                return(true);
            }

            return(false);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// A method to calculate the distance between
        /// this and another vector of type T.
        /// </summary>
        /// <param name="Vector">A vector of type T</param>
        /// <returns>The distance between this pixel and the given pixel.</returns>
        public T DistanceTo(IVector2D <T> Vector)
        {
            #region Initial Checks

            if (Vector == null)
            {
                throw new ArgumentNullException("The given vector must not be null!");
            }

            #endregion

            var dX = Math.Distance(X, Vector.X);
            var dY = Math.Distance(Y, Vector.Y);

            return(Math.Sqrt(Math.Add(Math.Mul(dX, dX), Math.Mul(dY, dY))));
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Get the position of an object in a grid.
        /// </summary>
        /// <typeparam name="T">Type of the object inside the grid.</typeparam>
        /// <param name="obj">The object to search for.</param>
        /// <param name="grid">The grid to search.</param>
        /// <returns>Return true if the object was found in the grid. Else return false.</returns>
        public static bool TryGetPositionOf <T>(T obj, IGrid <T> grid, out IVector2D <int> result)
        {
            var position = new IntVector2D();

            for (position.X = 0; position.X < grid.ColumnCount; position.X++)
            {
                for (position.Y = 0; position.Y < grid.RowCount; position.Y++)
                {
                    if (obj.Equals(grid.GetCellAt(position)))
                    {
                        result = position;
                        return(true);
                    }
                }
            }

            result = null;
            return(false);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Create a 2-dimensional vector of type T.
        /// </summary>
        /// <param name="Vector1">A vector of type T.</param>
        /// <param name="Vector2">A vector of type T.</param>
        public Vector2D(IVector2D <T> Vector1, IVector2D <T> Vector2)
        {
            #region Initial Checks

            if (Vector1 == null)
            {
                throw new ArgumentNullException("The first vector must not be null!");
            }

            if (Vector2 == null)
            {
                throw new ArgumentNullException("The second vector must not be null!");
            }

            #endregion

            this.Math = MathsFactory <T> .Instance;

            this.X      = Math.Sub(Vector1.X, Vector2.X);
            this.Y      = Math.Sub(Vector1.Y, Vector2.Y);
            this.Length = Vector1.DistanceTo(Vector2);
        }
Ejemplo n.º 24
0
        public static bool ColisionaEnemigoArma(IVector2D e)
        {
            foreach (var item in ArmasActivas)
            {
                if (VerificarColisionEnX(ArmasActivas[0], e) && VerificarColisionEnY(ArmasActivas[0], e))
                {
                    Engine.Debug("Colisiono: Arma");
                    Engine.Debug(ArmasActivas[0].LimiteBot.ToString());
                    Engine.Debug(ArmasActivas[0].LimiteTop.ToString());
                    Engine.Debug(ArmasActivas[0].LimiteIzquierda.ToString());
                    Engine.Debug(ArmasActivas[0].LimiteDerecha.ToString());

                    Engine.Debug("Colisiono: Enemigo");
                    Engine.Debug(e.LimiteBot.ToString());
                    Engine.Debug(e.LimiteTop.ToString());
                    Engine.Debug(e.LimiteIzquierda.ToString());
                    Engine.Debug(e.LimiteDerecha.ToString());

                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 25
0
 public Point(IVector2D position)
     : this()
 {
     Position = position;
 }
Ejemplo n.º 26
0
 public void Parse(GameBitBuffer buffer)
 {
     Field0 = buffer.ReadInt(32);
     Field1 = buffer.ReadInt(5) + (-1);
     Field2 = new IVector2D();
     Field2.Parse(buffer);
 }
Ejemplo n.º 27
0
 public bool Equals(IVector2D v)
 {
     return X.ApproximatelyEquals(v.X) && Y.ApproximatelyEquals(v.Y);
 }
Ejemplo n.º 28
0
 /// <summary>
 /// A method to calculate the square root of the vector.
 /// </summary>
 /// <param name="v">A vector.</param>
 /// <returns>The square root of v: Sqrt(v)</returns>
 public IVector2D <T> Sqrt(IVector2D <T> v)
 {
     return(new Vector2D <T>(Math.Sqrt(v.X),
                             Math.Sqrt(v.Y)));
 }
Ejemplo n.º 29
0
        public IVector2D Substract(IVector2D v)
        {
            IVector2D r = new Vector2D(X - v.X, Y - v.Y);

            return r;
        }
 public void Parse(GameBitBuffer buffer)
 {
     Field0 = buffer.ReadInt(32);
     Field1 = buffer.ReadInt(32);
     Field2 = buffer.ReadInt(32);
     Field3 = buffer.ReadInt(32);
     Field4 = buffer.ReadInt(32);
     Field5 = buffer.ReadInt(32);
     Field6 = new IVector2D();
     Field6.Parse(buffer);
 }
Ejemplo n.º 31
0
 public Rectangle(IVector2D origin, IVector2D size)
     : this()
 {
     Origin = origin;
     Size = size;
 }
Ejemplo n.º 32
0
 public Circle(IVector2D center, float radius)
     : this()
 {
     Center = center;
     Radius = radius;
 }
Ejemplo n.º 33
0
        public IVector2D ProjectOnto(IVector2D v)
        {
            float d = v.DotProduct(v);

            if (d > 0)
            {
                float dp = DotProduct(v);

                return v.Multiply(dp / d);
            }

            return v;
        }
Ejemplo n.º 34
0
        public Range ProjectOnto(IVector2D onto)
        {
            IVector2D ontoUnit = onto.UnitVector();

            float min = ontoUnit.DotProduct(Point1);
            float max = ontoUnit.DotProduct(Point2);
            var r = new Range(min, max);
            r = r.SortRange();

            return r;
        }
Ejemplo n.º 35
0
 public Rectangle2D(IVector2D start, IVector2D end)
 {
     m_Start = new Vector2D(start);
     m_End = new Vector2D(end);
 }
Ejemplo n.º 36
0
 public Line(IVector2D basee, IVector2D direction)
     : this()
 {
     Base = basee;
     Direction = direction;
 }
Ejemplo n.º 37
0
 public static IPixelPosition Move(this IPixelPosition me, IVector2D<uint> movement)
 {
     return new PixelPosition(me.X + movement.X, me.Y + movement.Y);
 }
Ejemplo n.º 38
0
 public void Parse(GameBitBuffer buffer)
 {
     Field0 = buffer.ReadInt(32);
     Field1 = new IVector2D();
     Field1.Parse(buffer);
     arSnoLevelAreas = new int[4];
     for(int i = 0;i < _arSnoLevelAreas.Length;i++) _arSnoLevelAreas[i] = buffer.ReadInt(32);
     snoPrevWorld = buffer.ReadInt(32);
     Field4 = buffer.ReadInt(32);
     snoPrevLevelArea = buffer.ReadInt(32);
     snoNextWorld = buffer.ReadInt(32);
     Field7 = buffer.ReadInt(32);
     snoNextLevelArea = buffer.ReadInt(32);
     snoMusic = buffer.ReadInt(32);
     snoCombatMusic = buffer.ReadInt(32);
     snoAmbient = buffer.ReadInt(32);
     snoReverb = buffer.ReadInt(32);
     snoWeather = buffer.ReadInt(32);
     snoPresetWorld = buffer.ReadInt(32);
     Field15 = buffer.ReadInt(32);
     Field16 = buffer.ReadInt(32);
     Field17 = buffer.ReadInt(32);
     Field18 = buffer.ReadInt(32);
     tCachedValues = new SceneCachedValues();
     tCachedValues.Parse(buffer);
 }
 public void Parse(GameBitBuffer buffer)
 {
     Field0 = buffer.ReadInt(2);
     Field1 = buffer.ReadInt(32);
     Field2 = buffer.ReadInt(32);
     Field3 = new IVector2D();
     Field3.Parse(buffer);
     serTiles = new SerializeData();
     serTiles.Parse(buffer);
     Field5 = new DT_VARIABLEARRAY();
     Field5.Parse(buffer);
 }
Ejemplo n.º 40
0
 public LineSegment(IVector2D point1, IVector2D point2)
     : this()
 {
     Point1 = point1;
     Point2 = point2;
 }
Ejemplo n.º 41
0
 /// <summary>
 /// Vectors collinearity check
 /// </summary>
 /// <remarks>
 /// If structures of type Vector are used - better way is call a static method IsCollinear
 /// </remarks>
 /// <param name="vector"></param>
 /// <returns></returns>
 public bool IsCollinearWith(IVector2D <double> other) => IsCollinear(this, other);
 public void Parse(GameBitBuffer buffer)
 {
     Field0 = buffer.ReadInt(32);
     dwWidth = buffer.ReadInt(32);
     dwHeight = buffer.ReadInt(32);
     dwFaceCount = buffer.ReadInt(32);
     Field4 = buffer.ReadInt(32);
     dwMipMapLevelMax = buffer.ReadInt(32);
     Field6 = new SerializeData[60];
     for(int i = 0;i < _Field6.Length;i++)
     {
         _Field6[i] = new SerializeData();
         _Field6[i].Parse(buffer);
     }
     Field7 = buffer.ReadInt(32);
     serFrame = new SerializeData();
     serFrame.Parse(buffer);
     Field9 = new DT_VARIABLEARRAY();
     Field9.Parse(buffer);
     Field10 = new IVector2D();
     Field10.Parse(buffer);
     Field11 = buffer.ReadInt(32);
     Field12 = buffer.ReadInt(32);
     Field13 = buffer.ReadInt(32);
     Field14 = buffer.ReadInt64(64);
     Field15 = buffer.ReadInt(32);
     Field16 = (byte)buffer.ReadInt(8);
     Field17 = (byte)buffer.ReadInt(8);
     Field18 = (byte)buffer.ReadInt(8);
     Field19 = buffer.ReadCharArray(256);
     Field20 = new DT_VARIABLEARRAY();
     Field20.Parse(buffer);
     serImageFileIDs = new SerializeData();
     serImageFileIDs.Parse(buffer);
     Field22 = buffer.ReadInt(32);
     Field23 = buffer.ReadInt(32);
     Field24 = buffer.ReadInt(32);
 }
Ejemplo n.º 43
0
 /// <summary>
 /// Get the scalar product of this vector and other
 /// </summary>
 /// <remarks>
 /// If structures of type Vector are used - better way is call a static method GetScalarProduct
 /// </remarks>
 /// <param name="other"></param>
 /// <returns></returns>
 public double GetScalarProductWith(IVector2D <double> other) => GetScalarProduct(this, other);
Ejemplo n.º 44
0
        public IVector2D Add(IVector2D v)
        {
            IVector2D r = new Vector2D(X + v.X, Y + v.Y);

            return r;
        }
Ejemplo n.º 45
0
 /// <summary>
 /// Get the angle between this vector and other in radians
 /// </summary>
 /// <remarks>
 /// If structures of type Vector are used - better way is call a static method GetAngleBetween
 /// </remarks>
 /// <param name="other"></param>
 /// <returns></returns>
 public double GetAngleWith(IVector2D <double> other) => GetAngleBetween(this, other);
Ejemplo n.º 46
0
 public float DotProduct(IVector2D v)
 {
     return X * v.X + Y * v.Y;
 }
Ejemplo n.º 47
0
 public static bool IsEquals(IVector2D <double> v1, IVector2D <double> v2) => v1.X == v2.X && v1.Y == v2.Y;
Ejemplo n.º 48
0
 public static IVector <T> AsVector <T>(this IVector2D <T> vector2D)
 {
     return(new Vector <T>(vector2D.DeltaX, vector2D.DeltaY));
 }
Ejemplo n.º 49
0
 /// <summary>
 /// A method to calculate the distance between two vectors.
 /// </summary>
 /// <param name="v1">A vector.</param>
 /// <param name="v2">A vector.</param>
 /// <returns>The distance between v1 and v2.</returns>
 public IVector2D <T> Distance(IVector2D <T> v1, IVector2D <T> v2)
 {
     return(new Vector2D <T>(Math.Abs(Math.Sub(v1.X, v2.X)),
                             Math.Abs(Math.Sub(v1.Y, v2.Y))));
 }
Ejemplo n.º 50
0
        public Rectangle EnlargeRectanglePoint(IVector2D point)
        {
            IVector2D origin = VectorFactory.GetVector2D(Origin.X.Minimum(point.X), Origin.Y.Minimum(point.Y));
            IVector2D size = VectorFactory.GetVector2D((Origin.X + Size.X).Maximum(point.X), (Origin.Y + Size.Y).Maximum(point.Y));
            size = size.Substract(origin);
            var enlarged = new Rectangle(origin, size);

            return enlarged;
        }
Ejemplo n.º 51
0
 /// <summary>
 /// Get the scalar product of vectors
 /// </summary>
 /// <param name="v1"></param>
 /// <param name="v2"></param>
 /// <returns></returns>
 public static double GetScalarProduct(IVector2D <double> v1, IVector2D <double> v2) => v1.X * v2.X + v1.Y * v2.Y;
Ejemplo n.º 52
0
        public static double GetScalarProduct(Vector v1, Vector v2) => v1.X * v2.X + v1.Y * v2.Y; //without boxing

        /// <summary>
        /// Get the angle between vectors in radians
        /// </summary>
        /// <param name="v1"></param>
        /// <param name="v2"></param>
        /// <returns></returns>
        public static double GetAngleBetween(IVector2D <double> v1, IVector2D <double> v2)
        {
            return(Math.Acos(GetScalarProduct(v1, v2) / (v1.Length * v2.Length)));
        }
Ejemplo n.º 53
0
 public bool Equals(IVector2D <double> other) => IsEquals(this, other);
Ejemplo n.º 54
0
 public int CompareTo(IVector2D <T> other)
 {
     throw new NotImplementedException();
 }
 public void Parse(GameBitBuffer buffer)
 {
     Field0 = buffer.ReadInt(32);
     Field1 = new DT_VARIABLEARRAY();
     Field1.Parse(buffer);
     serNavCells = new SerializeData();
     serNavCells.Parse(buffer);
     Field3 = buffer.ReadInt(32);
     Field4 = new DT_VARIABLEARRAY();
     Field4.Parse(buffer);
     serNavCellNeighbors = new SerializeData();
     serNavCellNeighbors.Parse(buffer);
     Field6 = buffer.ReadFloat32();
     Field7 = buffer.ReadFloat32();
     Field8 = buffer.ReadInt(32);
     Field9 = new IVector2D();
     Field9.Parse(buffer);
     Field10 = new DT_VARIABLEARRAY();
     Field10.Parse(buffer);
     serGridSquares = new SerializeData();
     serGridSquares.Parse(buffer);
     Field12 = buffer.ReadInt(32);
     Field13 = new DT_VARIABLEARRAY();
     Field13.Parse(buffer);
     serCellLookups = new SerializeData();
     serCellLookups.Parse(buffer);
     Field15 = buffer.ReadInt(32);
     Field16 = new DT_VARIABLEARRAY();
     Field16.Parse(buffer);
     serBorderData = new SerializeData();
     serBorderData.Parse(buffer);
 }
Ejemplo n.º 56
0
 public bool PositionIsOutOfBounds(IVector2D <int> position)
 {
     return(GridUtils.PositionIsOutOfBounds(position, this));
 }
Ejemplo n.º 57
0
 public bool Contains(IVector2D p)
 {
     return (m_Start <= p && m_End > p);
 }