Beispiel #1
0
        private const double Offset  = Segment / 2.0;     // offset the pieces by 1/2 their size

        /// <summary>
        /// Converts a direction vector to the closest Direction enum.
        /// </summary>
        /// <param name="vec"></param>
        /// <returns></returns>
        public static Direction GetDir(this Vector2 vec)
        {
            var ang = vec.ToAngle();

            if (ang < 0.0f) // convert -PI > PI to 0 > 2PI
            {
                ang += 2 * (float)Math.PI;
            }

            return((Direction)Math.Floor((ang + Offset) / Segment));
        }
        private const double Offset  = Segment / 2.0;     // offset the pieces by 1/2 their size

        /// <summary>
        /// Converts a direction vector to the closest Direction enum.
        /// </summary>
        /// <param name="vec"></param>
        /// <returns></returns>
        public static Direction GetDir(this Vector2 vec)
        {
            return(vec.ToAngle().GetDir());
        }