Ejemplo n.º 1
0
        public static Direction2D FromRotation(float degrees, Direction2D startDirection = Direction2D.Right) //
        {
            degrees = FlaiMath.RealModulus(degrees, 360);

            int step = (int)FlaiMath.Round(degrees / 90);

            return((Direction2D)FlaiMath.RealModulus((int)(step + startDirection), 4));
        }
Ejemplo n.º 2
0
        public static float Round(this RoundingOptions roundingOptions, float value)
        {
            switch (roundingOptions)
            {
            case RoundingOptions.Default:
                return((int)value);

            case RoundingOptions.Floor:
                return(FlaiMath.Floor(value));

            case RoundingOptions.Ceiling:
                return(FlaiMath.Ceiling(value));

            case RoundingOptions.Round:
                return(FlaiMath.Round(value));

            default:
                throw new ArgumentException("roundingOptions");
            }
        }
Ejemplo n.º 3
0
 public byte NextByte(byte min, byte max)
 {
     return((byte)FlaiMath.Round(min + base.NextDouble() * (max - min))); // 255 or 256?
 }
Ejemplo n.º 4
0
 public byte NextByte()
 {
     return((byte)FlaiMath.Round(base.NextDouble() * 255)); // 255 or 256?
 }
Ejemplo n.º 5
0
 public static Vector2i Round(Vector2 v)
 {
     return(new Vector2i((int)FlaiMath.Round(v.x), (int)FlaiMath.Round(v.y)));
 }
Ejemplo n.º 6
0
 public static Vector3i Round(Vector3 vec)
 {
     return(new Vector3i((int)FlaiMath.Round(vec.x), (int)FlaiMath.Round(vec.y), (int)FlaiMath.Round(vec.z)));
 }
Ejemplo n.º 7
0
 public static RectangleF GetRounded(RectangleF rectangle) // should this be non-static?
 {
     return(new RectangleF(FlaiMath.Round(rectangle.X), FlaiMath.Round(rectangle.Y), rectangle.Width, rectangle.Height));
 }