示例#1
0
        // TODO: Change to less case-specific methods (e.g. have vectors in input)
        // Angle between two vectors: one from a MovingEntity (origin to planned position), one with a new point (origin to a detected point)
        public static double AngleBetweenVectors(MovingEntity entity, MovingEntity newEntity)
        {
            Vector originalVector = new Vector(entity.DeltaX, entity.DeltaY);
            Vector newVector = new Vector(newEntity.Position.X - entity.Position.X, newEntity.Position.Y - entity.Position.Y);

            return Vector.AngleBetween(originalVector, newVector);
        }
示例#2
0
        // TODO: Change to less case-specific methods (e.g. have vectors in input)
        // Magnitude between two vectors
        public static double MagnitudeBetweenVectors(MovingEntity entity, MovingEntity newEntity)
        {
            double originalVectorMagnitude = DistanceBetweenPoints(new Position(entity.Position.X, entity.Position.Y),
                new Position(entity.Position.X + entity.DeltaX, entity.Position.Y + entity.DeltaY));
            double newVectorMagnitude = DistanceBetweenPoints(new Position(entity.Position.X, entity.Position.Y),
                new Position(newEntity.Position.X, newEntity.Position.Y));

            return Math.Abs(originalVectorMagnitude - newVectorMagnitude);
        }