public static long Pack(int xBits, int yBits, Vector2ul vector) { Contract.Requires(0 <= xBits && xBits <= 64, "xBits must be between 0 and 64 inclusive."); Contract.Requires(0 <= yBits && yBits <= 64, "yBits must be between 0 and 64 inclusive."); Contract.Requires(xBits + yBits <= 64); ulong x = (ulong)(vector.X) >> (64 - xBits); ulong y = (ulong)(vector.Y) >> (64 - yBits); y <<= xBits; return((long)(x | y)); }
public static PolarCoordinate CartesianToPolar(Vector2ul 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(Vector2ul value) { var absolute = Absolute(value); if (absolute <= double.Epsilon) { return(Vector2ul.Zero); } else { return((Vector2d)value / absolute); } }
public static bool All(Vector2ul value) { return(value.X != 0 && value.Y != 0); }
public static ulong Dot(Vector2ul left, Vector2ul 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(Vector2ul left, Vector2ul right) { return(left == right); }
/// <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 Vector2ul Divide(Vector2ul vector, ulong scalar) { return(new Vector2ul(vector.X / scalar, vector.Y / scalar)); }
public static Vector2sb Map(Vector2ul value, Func <ulong, sbyte> mapping) { return(new Vector2sb(mapping(value.X), mapping(value.Y))); }
public static ulong AbsoluteSquared(Vector2ul value) { return(Dot(value, value)); }
/// <summary> /// Writes the given <see cref="Vector2ul"/> to an <see cref="Ibasa.IO.BinaryWriter">. /// </summary> public static void Write(this Ibasa.IO.BinaryWriter writer, Vector2ul vector) { writer.Write(vector.X); writer.Write(vector.Y); }
public static Vector2ul Clamp(Vector2ul value, Vector2ul min, Vector2ul max) { return(new Vector2ul(Functions.Clamp(value.X, min.X, max.X), Functions.Clamp(value.Y, min.Y, max.Y))); }
public static Vector2ul Max(Vector2ul value1, Vector2ul value2) { return(new Vector2ul(Functions.Max(value1.X, value2.X), Functions.Max(value1.Y, value2.Y))); }
public static Vector2ul Abs(Vector2ul value) { return(new Vector2ul(Functions.Abs(value.X), Functions.Abs(value.Y))); }
public static Vector2ul Modulate(Vector2ul left, Vector2ul right) { return(new Vector2ul(left.X * right.X, left.Y * right.Y)); }
public static bool Any(Vector2ul value) { return(value.X != 0 || value.Y != 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 Vector2ul Add(Vector2ul left, Vector2ul right) { return(new Vector2ul(left.X + right.X, left.Y + right.Y)); }
public static bool Any(Vector2ul value, Predicate <ulong> predicate) { return(predicate(value.X) || predicate(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 Vector2ul Subtract(Vector2ul left, Vector2ul right) { return(new Vector2ul(left.X - right.X, left.Y - right.Y)); }
public static double Absolute(Vector2ul value) { return(Functions.Sqrt(AbsoluteSquared(value))); }
/// <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 Vector2ul Multiply(Vector2ul vector, ulong scalar) { return(new Vector2ul(vector.X * scalar, vector.Y * scalar)); }
public static Vector2d Map(Vector2ul value, Func <ulong, double> mapping) { return(new Vector2d(mapping(value.X), mapping(value.Y))); }
public static Vector2s Map(Vector2ul value, Func <ulong, short> mapping) { return(new Vector2s(mapping(value.X), mapping(value.Y))); }