public static ulong Pack(Vector2ui vector) { ulong x = (ulong)(vector.X) << 0; ulong y = (ulong)(vector.Y) << 32; return((ulong)(x | y)); }
/// <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; }
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)); }
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))); }
public static Vector2d Normalize(Vector2ui value) { var absolute = Absolute(value); if (absolute <= double.Epsilon) { return(Vector2ui.Zero); } else { return((Vector2d)value / absolute); } }
public static bool All(Vector2ui value) { return(value.X != 0 && value.Y != 0); }
public static uint Dot(Vector2ui left, Vector2ui right) { return(left.X * right.X + left.Y * right.Y); }
/// <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); }
public static Vector2sb Map(Vector2ui value, Func <uint, sbyte> mapping) { return(new Vector2sb(mapping(value.X), mapping(value.Y))); }
public static Vector2l Map(Vector2ui value, Func <uint, long> mapping) { return(new Vector2l(mapping(value.X), mapping(value.Y))); }
public static Vector2f Map(Vector2ui value, Func <uint, float> mapping) { return(new Vector2f(mapping(value.X), mapping(value.Y))); }
public static uint AbsoluteSquared(Vector2ui value) { return(Dot(value, value)); }
public static bool Any(Vector2ui value) { return(value.X != 0 || value.Y != 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); }
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))); }
public static Vector2ui Max(Vector2ui value1, Vector2ui value2) { return(new Vector2ui(Functions.Max(value1.X, value2.X), Functions.Max(value1.Y, value2.Y))); }
public static Vector2ui Abs(Vector2ui value) { return(new Vector2ui(Functions.Abs(value.X), Functions.Abs(value.Y))); }
public static Vector2ui Modulate(Vector2ui left, Vector2ui right) { return(new Vector2ui(left.X * right.X, left.Y * right.Y)); }
public static bool Any(Vector2ui value, Predicate <uint> predicate) { return(predicate(value.X) || predicate(value.Y)); }
/// <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)); }
public static double Absolute(Vector2ui value) { return(Functions.Sqrt(AbsoluteSquared(value))); }
/// <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)); }
public static Vector2d Map(Vector2ui value, Func <uint, double> mapping) { return(new Vector2d(mapping(value.X), mapping(value.Y))); }
/// <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)); }
public static Vector2h Map(Vector2ui value, Func <uint, Half> mapping) { return(new Vector2h(mapping(value.X), mapping(value.Y))); }
/// <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)); }
/// <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)); }
public static Vector2s Map(Vector2ui value, Func <uint, short> mapping) { return(new Vector2s(mapping(value.X), mapping(value.Y))); }