Exemplo n.º 1
0
        public static ulong Pack(Vector2ui vector)
        {
            ulong x = (ulong)(vector.X) << 0;
            ulong y = (ulong)(vector.Y) << 32;

            return((ulong)(x | y));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Vector8ui"/> 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 Vector8ui(Vector2ui value, uint v2, uint v3, uint v4, uint v5, uint v6, uint v7, uint v8, uint v9)
 {
     V0 = value.X;
     V1 = value.Y;
     V2 = v2;
     V3 = v3;
     V4 = v4;
     V5 = v5;
     V6 = v6;
     V7 = v7;
 }
Exemplo n.º 3
0
        public static ulong Pack(int xBits, int yBits, Vector2ui vector)
        {
            Contract.Requires(0 <= xBits && xBits <= 32, "xBits must be between 0 and 32 inclusive.");
            Contract.Requires(0 <= yBits && yBits <= 32, "yBits must be between 0 and 32 inclusive.");
            Contract.Requires(xBits + yBits <= 64);
            ulong x = (ulong)(vector.X) >> (64 - xBits);
            ulong y = (ulong)(vector.Y) >> (64 - yBits);

            y <<= xBits;
            return((ulong)(x | y));
        }
Exemplo n.º 4
0
        public static PolarCoordinate CartesianToPolar(Vector2ui 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)));
        }
Exemplo n.º 5
0
        public static Vector2d Normalize(Vector2ui value)
        {
            var absolute = Absolute(value);

            if (absolute <= double.Epsilon)
            {
                return(Vector2ui.Zero);
            }
            else
            {
                return((Vector2d)value / absolute);
            }
        }
Exemplo n.º 6
0
 public static bool All(Vector2ui value)
 {
     return(value.X != 0 && value.Y != 0);
 }
Exemplo n.º 7
0
 public static uint Dot(Vector2ui left, Vector2ui right)
 {
     return(left.X * right.X + left.Y * right.Y);
 }
Exemplo 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(Vector2ui left, Vector2ui right)
 {
     return(left == right);
 }
Exemplo n.º 9
0
 public static Vector2sb Map(Vector2ui value, Func <uint, sbyte> mapping)
 {
     return(new Vector2sb(mapping(value.X), mapping(value.Y)));
 }
Exemplo n.º 10
0
 public static Vector2l Map(Vector2ui value, Func <uint, long> mapping)
 {
     return(new Vector2l(mapping(value.X), mapping(value.Y)));
 }
Exemplo n.º 11
0
 public static Vector2f Map(Vector2ui value, Func <uint, float> mapping)
 {
     return(new Vector2f(mapping(value.X), mapping(value.Y)));
 }
Exemplo n.º 12
0
 public static uint AbsoluteSquared(Vector2ui value)
 {
     return(Dot(value, value));
 }
Exemplo n.º 13
0
 public static bool Any(Vector2ui value)
 {
     return(value.X != 0 || value.Y != 0);
 }
Exemplo n.º 14
0
 /// <summary>
 /// Writes the given <see cref="Vector2ui"/> to an <see cref="Ibasa.IO.BinaryWriter">.
 /// </summary>
 public static void Write(this Ibasa.IO.BinaryWriter writer, Vector2ui vector)
 {
     writer.Write(vector.X);
     writer.Write(vector.Y);
 }
Exemplo n.º 15
0
 public static Vector2ui Clamp(Vector2ui value, Vector2ui min, Vector2ui max)
 {
     return(new Vector2ui(Functions.Clamp(value.X, min.X, max.X), Functions.Clamp(value.Y, min.Y, max.Y)));
 }
Exemplo n.º 16
0
 public static Vector2ui Max(Vector2ui value1, Vector2ui value2)
 {
     return(new Vector2ui(Functions.Max(value1.X, value2.X), Functions.Max(value1.Y, value2.Y)));
 }
Exemplo n.º 17
0
 public static Vector2ui Abs(Vector2ui value)
 {
     return(new Vector2ui(Functions.Abs(value.X), Functions.Abs(value.Y)));
 }
Exemplo n.º 18
0
 public static Vector2ui Modulate(Vector2ui left, Vector2ui right)
 {
     return(new Vector2ui(left.X * right.X, left.Y * right.Y));
 }
Exemplo n.º 19
0
 public static bool Any(Vector2ui value, Predicate <uint> predicate)
 {
     return(predicate(value.X) || predicate(value.Y));
 }
Exemplo 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 Vector2l Negative(Vector2ui value)
 {
     return(new Vector2l(-value.X, -value.Y));
 }
Exemplo n.º 21
0
 public static double Absolute(Vector2ui value)
 {
     return(Functions.Sqrt(AbsoluteSquared(value)));
 }
Exemplo 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 Vector2ui Add(Vector2ui left, Vector2ui right)
 {
     return(new Vector2ui(left.X + right.X, left.Y + right.Y));
 }
Exemplo n.º 23
0
 public static Vector2d Map(Vector2ui value, Func <uint, double> mapping)
 {
     return(new Vector2d(mapping(value.X), mapping(value.Y)));
 }
Exemplo 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 Vector2ui Subtract(Vector2ui left, Vector2ui right)
 {
     return(new Vector2ui(left.X - right.X, left.Y - right.Y));
 }
Exemplo n.º 25
0
 public static Vector2h Map(Vector2ui value, Func <uint, Half> mapping)
 {
     return(new Vector2h(mapping(value.X), mapping(value.Y)));
 }
Exemplo 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 Vector2ui Multiply(Vector2ui vector, uint scalar)
 {
     return(new Vector2ui(vector.X * scalar, vector.Y * scalar));
 }
Exemplo 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 Vector2ui Divide(Vector2ui vector, uint scalar)
 {
     return(new Vector2ui(vector.X / scalar, vector.Y / scalar));
 }
Exemplo n.º 28
0
 public static Vector2s Map(Vector2ui value, Func <uint, short> mapping)
 {
     return(new Vector2s(mapping(value.X), mapping(value.Y)));
 }