Esempio n. 1
0
        public static uint Pack(Vector2us vector)
        {
            ulong x = (ulong)(vector.X) << 0;
            ulong y = (ulong)(vector.Y) << 16;

            return((uint)(x | y));
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Vector8us"/> using the specified vector and values.
 /// </summary>
 /// <param name="value">A vector containing the values with which to initialize the first 2 components</param>
 /// <param name="v2">Value for the V2 component of the vector.</param>
 /// <param name="v3">Value for the V3 component of the vector.</param>
 /// <param name="v4">Value for the V4 component of the vector.</param>
 /// <param name="v5">Value for the V5 component of the vector.</param>
 /// <param name="v6">Value for the V6 component of the vector.</param>
 /// <param name="v7">Value for the V7 component of the vector.</param>
 public Vector8us(Vector2us value, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7, ushort v8, ushort v9)
 {
     V0 = value.X;
     V1 = value.Y;
     V2 = v2;
     V3 = v3;
     V4 = v4;
     V5 = v5;
     V6 = v6;
     V7 = v7;
 }
Esempio n. 3
0
        public static uint Pack(int xBits, int yBits, Vector2us vector)
        {
            Contract.Requires(0 <= xBits && xBits <= 16, "xBits must be between 0 and 16 inclusive.");
            Contract.Requires(0 <= yBits && yBits <= 16, "yBits must be between 0 and 16 inclusive.");
            Contract.Requires(xBits + yBits <= 32);
            ulong x = (ulong)(vector.X) >> (32 - xBits);
            ulong y = (ulong)(vector.Y) >> (32 - yBits);

            y <<= xBits;
            return((uint)(x | y));
        }
Esempio n. 4
0
        public static PolarCoordinate CartesianToPolar(Vector2us value)
        {
            double theta = Functions.Atan2(value.Y, value.X);

            if (theta < 0)
            {
                theta += 2 * Constants.Pi;
            }
            return(new PolarCoordinate(
                       theta,
                       (double)Functions.Sqrt(value.X * value.X + value.Y * value.Y)));
        }
Esempio n. 5
0
        public static Vector2f Normalize(Vector2us value)
        {
            var absolute = Absolute(value);

            if (absolute <= float.Epsilon)
            {
                return(Vector2us.Zero);
            }
            else
            {
                return((Vector2f)value / absolute);
            }
        }
Esempio n. 6
0
 public static bool All(Vector2us value)
 {
     return(value.X != 0 && value.Y != 0);
 }
Esempio n. 7
0
 public static int Dot(Vector2us left, Vector2us right)
 {
     return(left.X * right.X + left.Y * right.Y);
 }
Esempio n. 8
0
 /// <summary>
 /// Returns a value that indicates whether two vectors are equal.
 /// </summary>
 /// <param name="left">The first vector to compare.</param>
 /// <param name="right">The second vector to compare.</param>
 /// <returns>true if the left and right are equal; otherwise, false.</returns>
 public static bool Equals(Vector2us left, Vector2us right)
 {
     return(left == right);
 }
Esempio n. 9
0
 public static Vector2sb Map(Vector2us value, Func <ushort, sbyte> mapping)
 {
     return(new Vector2sb(mapping(value.X), mapping(value.Y)));
 }
Esempio n. 10
0
 public static Vector2l Map(Vector2us value, Func <ushort, long> mapping)
 {
     return(new Vector2l(mapping(value.X), mapping(value.Y)));
 }
Esempio n. 11
0
 public static Vector2f Map(Vector2us value, Func <ushort, float> mapping)
 {
     return(new Vector2f(mapping(value.X), mapping(value.Y)));
 }
Esempio n. 12
0
 public static int AbsoluteSquared(Vector2us value)
 {
     return(Dot(value, value));
 }
Esempio n. 13
0
 public static bool Any(Vector2us value)
 {
     return(value.X != 0 || value.Y != 0);
 }
Esempio n. 14
0
 /// <summary>
 /// Writes the given <see cref="Vector2us"/> to an <see cref="Ibasa.IO.BinaryWriter">.
 /// </summary>
 public static void Write(this Ibasa.IO.BinaryWriter writer, Vector2us vector)
 {
     writer.Write(vector.X);
     writer.Write(vector.Y);
 }
Esempio n. 15
0
 public static Vector2us Clamp(Vector2us value, Vector2us min, Vector2us max)
 {
     return(new Vector2us(Functions.Clamp(value.X, min.X, max.X), Functions.Clamp(value.Y, min.Y, max.Y)));
 }
Esempio n. 16
0
 public static Vector2us Max(Vector2us value1, Vector2us value2)
 {
     return(new Vector2us(Functions.Max(value1.X, value2.X), Functions.Max(value1.Y, value2.Y)));
 }
Esempio n. 17
0
 public static Vector2us Abs(Vector2us value)
 {
     return(new Vector2us(Functions.Abs(value.X), Functions.Abs(value.Y)));
 }
Esempio n. 18
0
 public static Vector2i Modulate(Vector2us left, Vector2us right)
 {
     return(new Vector2i(left.X * right.X, left.Y * right.Y));
 }
Esempio n. 19
0
 public static bool Any(Vector2us value, Predicate <ushort> predicate)
 {
     return(predicate(value.X) || predicate(value.Y));
 }
Esempio n. 20
0
 /// <summary>
 /// Returns the additive inverse of a vector.
 /// </summary>
 /// <param name="value">A vector.</param>
 /// <returns>The negative of value.</returns>
 public static Vector2i Negative(Vector2us value)
 {
     return(new Vector2i(-value.X, -value.Y));
 }
Esempio n. 21
0
 public static float Absolute(Vector2us value)
 {
     return(Functions.Sqrt(AbsoluteSquared(value)));
 }
Esempio n. 22
0
 /// <summary>
 /// Adds two vectors and returns the result.
 /// </summary>
 /// <param name="left">The first value to add.</param>
 /// <param name="right">The second value to add.</param>
 /// <returns>The sum of left and right.</returns>
 public static Vector2i Add(Vector2us left, Vector2us right)
 {
     return(new Vector2i(left.X + right.X, left.Y + right.Y));
 }
Esempio n. 23
0
 public static Vector2d Map(Vector2us value, Func <ushort, double> mapping)
 {
     return(new Vector2d(mapping(value.X), mapping(value.Y)));
 }
Esempio n. 24
0
 /// <summary>
 /// Subtracts one vectors from another and returns the result.
 /// </summary>
 /// <param name="left">The value to subtract from (the minuend).</param>
 /// <param name="right">The value to subtract (the subtrahend).</param>
 /// <returns>The result of subtracting right from left (the difference).</returns>
 public static Vector2i Subtract(Vector2us left, Vector2us right)
 {
     return(new Vector2i(left.X - right.X, left.Y - right.Y));
 }
Esempio n. 25
0
 public static Vector2h Map(Vector2us value, Func <ushort, Half> mapping)
 {
     return(new Vector2h(mapping(value.X), mapping(value.Y)));
 }
Esempio n. 26
0
 /// <summary>
 /// Returns the product of a vector and scalar.
 /// </summary>
 /// <param name="vector">The vector to multiply.</param>
 /// <param name="scalar">The scalar to multiply.</param>
 /// <returns>The product of the left and right parameters.</returns>
 public static Vector2i Multiply(Vector2us vector, int scalar)
 {
     return(new Vector2i(vector.X * scalar, vector.Y * scalar));
 }
Esempio n. 27
0
 /// <summary>
 /// Divides a vector by a scalar and returns the result.
 /// </summary>
 /// <param name="vector">The vector to be divided (the dividend).</param>
 /// <param name="scalar">The scalar to divide by (the divisor).</param>
 /// <returns>The result of dividing left by right (the quotient).</returns>
 public static Vector2i Divide(Vector2us vector, int scalar)
 {
     return(new Vector2i(vector.X / scalar, vector.Y / scalar));
 }
Esempio n. 28
0
 public static Vector2i Map(Vector2us value, Func <ushort, int> mapping)
 {
     return(new Vector2i(mapping(value.X), mapping(value.Y)));
 }