/// <summary> /// Converts the given value object to the specified type, using the specified context and culture information. /// </summary> /// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param> /// <param name="culture">A <see cref="System.Globalization.CultureInfo"/> object. If a null reference (Nothing in Visual Basic) is passed, the current culture is assumed.</param> /// <param name="value">The <see cref="Object"/> to convert.</param> /// <param name="destinationType">The Type to convert the <paramref name="value"/> parameter to.</param> /// <returns>An <see cref="Object"/> that represents the converted value.</returns> public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType) { if ((destinationType == typeof(string)) && (value is Vector4F)) { Vector4F v = (Vector4F)value; return(v.ToString()); } return(base.ConvertTo(context, culture, value, destinationType)); }
/// <summary> /// Determines whether the <see cref="Vector4FArrayList"/> /// contains the specified <see cref="Vector4F"/> element. /// </summary> /// <param name="value">The <see cref="Vector4F"/> object /// to locate in the <see cref="Vector4FArrayList"/>. /// </param> /// <returns><c>true</c> if <paramref name="value"/> is found in the /// <see cref="Vector4FArrayList"/>; otherwise, <c>false</c>.</returns> /// <remarks>Please refer to <see cref="ArrayList.Contains"/> for details.</remarks> public bool Contains(Vector4F value) { return (IndexOf(value) >= 0); }
/// <summary> /// Transforms a given vector by a matrix. /// </summary> /// <param name="matrix">A <see cref="Matrix4F"/> instance.</param> /// <param name="vector">A <see cref="Vector4F"/> instance.</param> /// <returns>A new <see cref="Vector4F"/> instance containing the result.</returns> public static Vector4F Transform(Matrix4F matrix, Vector4F vector) { return new Vector4F( (matrix.M11 * vector.X) + (matrix.M12 * vector.Y) + (matrix.M13 * vector.Z) + (matrix.M14 * vector.W), (matrix.M21 * vector.X) + (matrix.M22 * vector.Y) + (matrix.M23 * vector.Z) + (matrix.M24 * vector.W), (matrix.M31 * vector.X) + (matrix.M32 * vector.Y) + (matrix.M33 * vector.Z) + (matrix.M34 * vector.W), (matrix.M41 * vector.X) + (matrix.M42 * vector.Y) + (matrix.M43 * vector.Z) + (matrix.M44 * vector.W)); }
/// <summary> /// Adds two vectors. /// </summary> /// <param name="u">A <see cref="Vector4F"/> instance.</param> /// <param name="v">A <see cref="Vector4F"/> instance.</param> /// <returns>A new <see cref="Vector4F"/> instance containing the sum.</returns> public static Vector4F operator+(Vector4F u, Vector4F v) { return(Vector4F.Add(u, v)); }
/// <summary> /// Subtracts a scalar from a vector. /// </summary> /// <param name="v">A <see cref="Vector4F"/> instance.</param> /// <param name="s">A scalar.</param> /// <returns>A new <see cref="Vector4F"/> instance containing the difference.</returns> /// <remarks> /// result[i] = s - v[i] /// </remarks> public static Vector4F operator-(float s, Vector4F v) { return(Vector4F.Subtract(s, v)); }
/// <summary> /// Divides a vector by another vector. /// </summary> /// <param name="u">A <see cref="Vector4F"/> instance.</param> /// <param name="v">A <see cref="Vector4F"/> instance.</param> /// <returns>A new <see cref="Vector4F"/> containing the quotient.</returns> /// <remarks> /// result[i] = u[i] / v[i]. /// </remarks> public static Vector4F Divide(Vector4F u, Vector4F v) { return(new Vector4F(u.X / v.X, u.Y / v.Y, u.Z / v.Z, u.W / v.W)); }
/// <summary> /// Calculates the dot product of two vectors. /// </summary> /// <param name="u">A <see cref="Vector4F"/> instance.</param> /// <param name="v">A <see cref="Vector4F"/> instance.</param> /// <returns>The dot product value.</returns> public static float Dot(Vector4F u, Vector4F v) { return((u.X * v.X) + (u.Y * v.Y) + (u.Z * v.Z) + (u.W * v.W)); }
/// <summary> /// Copies the elements of the <see cref="Vector4FArrayList"/> to a new /// <see cref="Array"/> of <see cref="Vector4F"/> elements. /// </summary> /// <returns>A one-dimensional <see cref="Array"/> of <see cref="Vector4F"/> /// elements containing copies of the elements of the <see cref="Vector4FArrayList"/>.</returns> /// <remarks>Please refer to <see cref="ArrayList.ToArray"/> for details.</remarks> public virtual Vector4F[] ToArray() { Vector4F[] array = new Vector4F[this._count]; Array.Copy(this._array, array, this._count); return array; }
public override void AddRange(Vector4F[] array) { throw new NotSupportedException( "Read-only collections cannot be modified."); }
/// <summary> /// Inserts a <see cref="Vector4F"/> element into the /// <see cref="Vector4FArrayList"/> at the specified index. /// </summary> /// <param name="index">The zero-based index at which <paramref name="value"/> /// should be inserted.</param> /// <param name="value">The <see cref="Vector4F"/> object /// to insert into the <see cref="Vector4FArrayList"/>. /// </param> /// <exception cref="ArgumentOutOfRangeException"> /// <para><paramref name="index"/> is less than zero.</para> /// <para>-or-</para> /// <para><paramref name="index"/> is greater than <see cref="Count"/>.</para> /// </exception> /// <exception cref="NotSupportedException"> /// <para>The <see cref="Vector4FArrayList"/> is read-only.</para> /// <para>-or-</para> /// <para>The <b>Vector4FArrayList</b> has a fixed size.</para> /// <para>-or-</para> /// <para>The <b>Vector4FArrayList</b> already contains the specified /// <paramref name="value"/>, and the <b>Vector4FArrayList</b> /// ensures that all elements are unique.</para></exception> /// <remarks>Please refer to <see cref="ArrayList.Insert"/> for details.</remarks> public virtual void Insert(int index, Vector4F value) { if (index < 0) throw new ArgumentOutOfRangeException("index", index, "Argument cannot be negative."); if (index > this._count) throw new ArgumentOutOfRangeException("index", index, "Argument cannot exceed Count."); if (this._count == this._array.Length) EnsureCapacity(this._count + 1); ++this._version; if (index < this._count) Array.Copy(this._array, index, this._array, index + 1, this._count - index); this._array[index] = value; ++this._count; }
/// <summary> /// Removes the first occurrence of the specified <see cref="Vector4F"/> /// from the <see cref="Vector4FArrayList"/>. /// </summary> /// <param name="value">The <see cref="Vector4F"/> object /// to remove from the <see cref="Vector4FArrayList"/>. /// </param> /// <exception cref="NotSupportedException"> /// <para>The <see cref="Vector4FArrayList"/> is read-only.</para> /// <para>-or-</para> /// <para>The <b>Vector4FArrayList</b> has a fixed size.</para></exception> /// <remarks>Please refer to <see cref="ArrayList.Remove"/> for details.</remarks> public virtual void Remove(Vector4F value) { int index = IndexOf(value); if (index >= 0) RemoveAt(index); }
/// <summary> /// Returns the zero-based index of the first occurrence of the specified /// <see cref="Vector4F"/> in the <see cref="Vector4FArrayList"/>. /// </summary> /// <param name="value">The <see cref="Vector4F"/> object /// to locate in the <see cref="Vector4FArrayList"/>. /// </param> /// <returns> /// The zero-based index of the first occurrence of <paramref name="value"/> /// in the <see cref="Vector4FArrayList"/>, if found; otherwise, -1. /// </returns> /// <remarks>Please refer to <see cref="ArrayList.IndexOf"/> for details.</remarks> public virtual int IndexOf(Vector4F value) { return Array.IndexOf(this._array, value, 0, this._count); }
/// <summary> /// Copies the entire <see cref="Vector4FArrayList"/> to a one-dimensional <see cref="Array"/> /// of <see cref="Vector4F"/> elements, starting at the specified index of the target array. /// </summary> /// <param name="array">The one-dimensional <see cref="Array"/> that is the destination of the /// <see cref="Vector4F"/> elements copied from the <see cref="Vector4FArrayList"/>. /// The <b>Array</b> must have zero-based indexing.</param> /// <param name="arrayIndex">The zero-based index in <paramref name="array"/> /// at which copying begins.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="array"/> is a null reference.</exception> /// <exception cref="ArgumentOutOfRangeException"> /// <paramref name="arrayIndex"/> is less than zero.</exception> /// <exception cref="ArgumentException"><para> /// <paramref name="arrayIndex"/> is equal to or greater than the length of <paramref name="array"/>. /// </para><para>-or-</para><para> /// The number of elements in the source <see cref="Vector4FArrayList"/> is greater than the /// available space from <paramref name="arrayIndex"/> to the end of the destination /// <paramref name="array"/>.</para></exception> /// <remarks>Please refer to <see cref="ArrayList.CopyTo"/> for details.</remarks> public virtual void CopyTo(Vector4F[] array, int arrayIndex) { CheckTargetArray(array, arrayIndex); Array.Copy(this._array, 0, array, arrayIndex, this._count); }
/// <overloads> /// Copies the <see cref="Vector4FArrayList"/> or a portion of it to a one-dimensional array. /// </overloads> /// <summary> /// Copies the entire <see cref="Vector4FArrayList"/> to a one-dimensional <see cref="Array"/> /// of <see cref="Vector4F"/> elements, starting at the beginning of the target array. /// </summary> /// <param name="array">The one-dimensional <see cref="Array"/> that is the destination of the /// <see cref="Vector4F"/> elements copied from the <see cref="Vector4FArrayList"/>. /// The <b>Array</b> must have zero-based indexing.</param> /// <exception cref="ArgumentNullException"> /// <paramref name="array"/> is a null reference.</exception> /// <exception cref="ArgumentException"> /// The number of elements in the source <see cref="Vector4FArrayList"/> is greater /// than the available space in the destination <paramref name="array"/>.</exception> /// <remarks>Please refer to <see cref="ArrayList.CopyTo"/> for details.</remarks> public virtual void CopyTo(Vector4F[] array) { CheckTargetArray(array, 0); Array.Copy(this._array, array, this._count); }
/// <summary> /// Adds a vector and a scalar. /// </summary> /// <param name="v">A <see cref="Vector4F"/> instance.</param> /// <param name="s">A scalar.</param> /// <returns>A new <see cref="Vector4F"/> instance containing the sum.</returns> public static Vector4F Add(Vector4F v, float s) { return(new Vector4F(v.X + s, v.Y + s, v.Z + s, v.W + s)); }
public override void Insert(int index, Vector4F value) { throw new NotSupportedException( "Read-only collections cannot be modified."); }
/// <summary> /// Subtracts a scalar from a vector. /// </summary> /// <param name="v">A <see cref="Vector4F"/> instance.</param> /// <param name="s">A scalar.</param> /// <returns>A new <see cref="Vector4F"/> instance containing the difference.</returns> /// <remarks> /// result[i] = v[i] - s /// </remarks> public static Vector4F Subtract(Vector4F v, float s) { return(new Vector4F(v.X - s, v.Y - s, v.Z - s, v.W - s)); }
public override void Remove(Vector4F value) { throw new NotSupportedException( "Read-only collections cannot be modified."); }
/// <summary> /// Divides a scalar by a vector. /// </summary> /// <param name="v">A <see cref="Vector4F"/> instance.</param> /// <param name="s">A scalar</param> /// <returns>A new <see cref="Vector4F"/> containing the quotient.</returns> /// <remarks> /// result[i] = s / v[i] /// </remarks> public static Vector4F Divide(float s, Vector4F v) { return(new Vector4F(s / v.X, s / v.Y, s / v.Z, s / v.W)); }
public override int Add(Vector4F value) { lock (this._root) return this._collection.Add(value); }
/// <summary> /// Tests whether two vectors are approximately equal using default tolerance value. /// </summary> /// <param name="v">A <see cref="Vector4F"/> instance.</param> /// <param name="u">A <see cref="Vector4F"/> instance.</param> /// <returns><see langword="true"/> if the two vectors are approximately equal; otherwise, <see langword="false"/>.</returns> public static bool ApproxEqual(Vector4F v, Vector4F u) { return(ApproxEqual(v, u, MathFunctions.EpsilonF)); }
public override void AddRange(Vector4F[] array) { lock (this._root) this._collection.AddRange(array); }
/// <summary> /// Subtracts a vector from a vector. /// </summary> /// <param name="u">A <see cref="Vector4F"/> instance.</param> /// <param name="v">A <see cref="Vector4F"/> instance.</param> /// <returns>A new <see cref="Vector4F"/> instance containing the difference.</returns> /// <remarks> /// result[i] = v[i] - w[i]. /// </remarks> public static Vector4F operator-(Vector4F u, Vector4F v) { return(Vector4F.Subtract(u, v)); }
public override void CopyTo(Vector4F[] array) { lock (this._root) this._collection.CopyTo(array); }
/// <summary> /// Divides a vector by a scalar. /// </summary> /// <param name="v">A <see cref="Vector4F"/> instance.</param> /// <param name="s">A scalar</param> /// <returns>A new <see cref="Vector4F"/> containing the quotient.</returns> /// <remarks> /// result[i] = v[i] / s; /// </remarks> public static Vector4F operator/(Vector4F v, float s) { return(Vector4F.Divide(v, s)); }
public override void Insert(int index, Vector4F value) { lock (this._root) this._collection.Insert(index, value); }
/// <summary> /// Initializes a new instance of the <see cref="Matrix4F"/> structure with the specified values. /// </summary> /// <param name="column1">A <see cref="Vector2D"/> instance holding values for the first column.</param> /// <param name="column2">A <see cref="Vector2D"/> instance holding values for the second column.</param> /// <param name="column3">A <see cref="Vector2D"/> instance holding values for the third column.</param> /// <param name="column4">A <see cref="Vector2D"/> instance holding values for the fourth column.</param> public Matrix4F(Vector4F column1, Vector4F column2, Vector4F column3, Vector4F column4) { _m11 = column1.X; _m12 = column2.X; _m13 = column3.X; _m14 = column4.X; _m21 = column1.Y; _m22 = column2.Y; _m23 = column3.Y; _m24 = column4.Y; _m31 = column1.Z; _m32 = column2.Z; _m33 = column3.Z; _m34 = column4.Z; _m41 = column1.W; _m42 = column2.W; _m43 = column3.W; _m44 = column4.W; }
public override void Remove(Vector4F value) { lock (this._root) this._collection.Remove(value); }
/// <summary> /// Transforms a given vector by a matrix and put the result in a vector. /// </summary> /// <param name="matrix">A <see cref="Matrix4F"/> instance.</param> /// <param name="vector">A <see cref="Vector4F"/> instance.</param> /// <param name="result">A <see cref="Vector4F"/> instance to hold the result.</param> public static void Transform(Matrix4F matrix, Vector4F vector, ref Vector4F result) { result.X = (matrix.M11 * vector.X) + (matrix.M12 * vector.Y) + (matrix.M13 * vector.Z) + (matrix.M14 * vector.W); result.Y = (matrix.M21 * vector.X) + (matrix.M22 * vector.Y) + (matrix.M23 * vector.Z) + (matrix.M24 * vector.W); result.Z = (matrix.M31 * vector.X) + (matrix.M32 * vector.Y) + (matrix.M33 * vector.Z) + (matrix.M34 * vector.W); result.W = (matrix.M41 * vector.X) + (matrix.M42 * vector.Y) + (matrix.M43 * vector.Z) + (matrix.M44 * vector.W); }
public override int Add(Vector4F value) { CheckUnique(value); return this._collection.Add(value); }
/// <summary> /// Adds two vectors. /// </summary> /// <param name="v">A <see cref="Vector4F"/> instance.</param> /// <param name="w">A <see cref="Vector4F"/> instance.</param> /// <returns>A new <see cref="Vector4F"/> instance containing the sum.</returns> public static Vector4F Add(Vector4F v, Vector4F w) { return(new Vector4F(v.X + w.X, v.Y + w.Y, v.Z + w.Z, v.W + w.W)); }
public override void AddRange(Vector4F[] array) { foreach (Vector4F value in array) CheckUnique(value); this._collection.AddRange(array); }
/// <summary> /// Subtracts a vector from a vector. /// </summary> /// <param name="v">A <see cref="Vector4F"/> instance.</param> /// <param name="w">A <see cref="Vector4F"/> instance.</param> /// <returns>A new <see cref="Vector4F"/> instance containing the difference.</returns> /// <remarks> /// result[i] = v[i] - w[i]. /// </remarks> public static Vector4F Subtract(Vector4F v, Vector4F w) { return(new Vector4F(v.X - w.X, v.Y - w.Y, v.Z - w.Z, v.W - w.W)); }
public override int BinarySearch(Vector4F value) { return this._collection.BinarySearch(value); }
/// <summary> /// Subtracts a vector from a scalar. /// </summary> /// <param name="v">A <see cref="Vector4F"/> instance.</param> /// <param name="s">A scalar.</param> /// <returns>A new <see cref="Vector4F"/> instance containing the difference.</returns> /// <remarks> /// result[i] = s - v[i] /// </remarks> public static Vector4F Subtract(float s, Vector4F v) { return(new Vector4F(s - v.X, s - v.Y, s - v.Z, s - v.W)); }
public override void CopyTo(Vector4F[] array) { this._collection.CopyTo(array); }
/// <summary> /// Divides a vector by a scalar. /// </summary> /// <param name="v">A <see cref="Vector4F"/> instance.</param> /// <param name="s">A scalar</param> /// <returns>A new <see cref="Vector4F"/> containing the quotient.</returns> /// <remarks> /// result[i] = v[i] / s; /// </remarks> public static Vector4F Divide(Vector4F v, float s) { return(new Vector4F(v.X / s, v.Y / s, v.Z / s, v.W / s)); }
public override void CopyTo(Vector4F[] array, int arrayIndex) { this._collection.CopyTo(array, arrayIndex); }
/// <summary> /// Multiplies a vector by a scalar. /// </summary> /// <param name="u">A <see cref="Vector4F"/> instance.</param> /// <param name="s">A scalar.</param> /// <returns>A new <see cref="Vector4F"/> containing the result.</returns> public static Vector4F Multiply(Vector4F u, float s) { return(new Vector4F(u.X * s, u.Y * s, u.Z * s, u.W * s)); }
public override int IndexOf(Vector4F value) { return this._collection.IndexOf(value); }
/// <summary> /// Negates a vector. /// </summary> /// <param name="v">A <see cref="Vector4F"/> instance.</param> /// <returns>A new <see cref="Vector4F"/> instance containing the negated values.</returns> public static Vector4F Negate(Vector4F v) { return(new Vector4F(-v.X, -v.Y, -v.Z, -v.W)); }
public override void Insert(int index, Vector4F value) { CheckUnique(value); this._collection.Insert(index, value); }
/// <summary> /// Negates the values of the vector. /// </summary> /// <param name="v">A <see cref="Vector4F"/> instance.</param> /// <returns>A new <see cref="Vector4F"/> instance containing the negated values.</returns> public static Vector4F operator-(Vector4F v) { return(Vector4F.Negate(v)); }
public override void Remove(Vector4F value) { this._collection.Remove(value); }
/// <summary> /// Adds a vector and a scalar. /// </summary> /// <param name="v">A <see cref="Vector4F"/> instance.</param> /// <param name="s">A scalar.</param> /// <returns>A new <see cref="Vector4F"/> instance containing the sum.</returns> public static Vector4F operator+(float s, Vector4F v) { return(Vector4F.Add(v, s)); }
private void CheckUnique(Vector4F value) { if (IndexOf(value) >= 0) throw new NotSupportedException( "Unique collections cannot contain duplicate elements."); }
/// <summary> /// Subtracts a vector from a scalar. /// </summary> /// <param name="v">A <see cref="Vector4F"/> instance.</param> /// <param name="s">A scalar.</param> /// <returns>A new <see cref="Vector4F"/> instance containing the difference.</returns> /// <remarks> /// result[i] = v[i] - s /// </remarks> public static Vector4F operator-(Vector4F v, float s) { return(Vector4F.Subtract(v, s)); }
private void CheckUnique(int index, Vector4F value) { int existing = IndexOf(value); if (existing >= 0 && existing != index) throw new NotSupportedException( "Unique collections cannot contain duplicate elements."); }
/// <summary> /// Multiplies a vector by a scalar. /// </summary> /// <param name="v">A <see cref="Vector4F"/> instance.</param> /// <param name="s">A scalar.</param> /// <returns>A new <see cref="Vector4F"/> containing the result.</returns> public static Vector4F operator*(float s, Vector4F v) { return(Vector4F.Multiply(v, s)); }
/// <summary> /// Builds a matrix that flattens geometry into a plane. /// </summary> /// <param name="lightPosition">A <see cref="Vector4F"/> instance representing the light source position.</param> /// <param name="p">A <see cref="Plane"/> instance.</param> /// <returns>A <see cref="Matrix4F"/> representing the shadow transformation.</returns> /// <remarks> /// This method flattens geometry into a plane, as if it were casting a shadow from a light. /// </remarks> public static Matrix4F Shadow(Vector4F lightPosition, Plane p) { // TODO: Implement this. throw new NotImplementedException(); }
/// <summary> /// Divides a scalar by a vector. /// </summary> /// <param name="v">A <see cref="Vector4F"/> instance.</param> /// <param name="s">A scalar</param> /// <returns>A new <see cref="Vector4F"/> containing the quotient.</returns> /// <remarks> /// result[i] = s / v[i] /// </remarks> public static Vector4F operator/(float s, Vector4F v) { return(Vector4F.Divide(s, v)); }
/// <summary> /// Searches the entire sorted <see cref="Vector4FArrayList"/> for an /// <see cref="Vector4F"/> element using the default comparer /// and returns the zero-based index of the element. /// </summary> /// <param name="value">The <see cref="Vector4F"/> object /// to locate in the <see cref="Vector4FArrayList"/>. /// </param> /// <returns>The zero-based index of <paramref name="value"/> in the sorted /// <see cref="Vector4FArrayList"/>, if <paramref name="value"/> is found; /// otherwise, a negative number, which is the bitwise complement of the index /// of the next element that is larger than <paramref name="value"/> or, if there /// is no larger element, the bitwise complement of <see cref="Count"/>.</returns> /// <exception cref="InvalidOperationException"> /// Neither <paramref name="value"/> nor the elements of the <see cref="Vector4FArrayList"/> /// implement the <see cref="IComparable"/> interface.</exception> /// <remarks>Please refer to <see cref="ArrayList.BinarySearch"/> for details.</remarks> public virtual int BinarySearch(Vector4F value) { return Array.BinarySearch(this._array, 0, this._count, value); }