/// <summary> /// Converts the given object to the type of this converter, using the specified context and culture information. /// </summary> /// <param name="context">An <see cref="ITypeDescriptorContext"/> that provides a format context.</param> /// <param name="culture">The <see cref="System.Globalization.CultureInfo"/> to use as the current culture. </param> /// <param name="value">The <see cref="Object"/> to convert.</param> /// <returns>An <see cref="Object"/> that represents the converted value.</returns> /// <exception cref="ParseException">Failed parsing from string.</exception> public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value) { if (value.GetType() == typeof(string)) { return(Vector4F.Parse((string)value)); } return(base.ConvertFrom(context, culture, value)); }
/// <summary> /// Tests whether two vectors are approximately equal given a tolerance value. /// </summary> /// <param name="left">A <see cref="Vector4F"/> instance.</param> /// <param name="right">A <see cref="Vector4F"/> instance.</param> /// <param name="tolerance">The tolerance value used to test approximate equality.</param> /// <returns><see langword="true"/> if the two vectors are approximately equal; otherwise, <see langword="false"/>.</returns> public static bool ApproxEqual(Vector4F left, Vector4F right, float tolerance) { return ( (System.Math.Abs(left.X - right.X) <= tolerance) && (System.Math.Abs(left.Y - right.Y) <= tolerance) && (System.Math.Abs(left.Z - right.Z) <= tolerance) && (System.Math.Abs(left.W - right.W) <= tolerance) ); }
/// <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> /// Converts the specified string to its <see cref="Vector4F"/> equivalent. /// A return value indicates whether the conversion succeeded or failed. /// </summary> /// <param name="value">A string representation of a <see cref="Vector4F"/>.</param> /// <param name="result"> /// When this method returns, if the conversion succeeded, /// contains a <see cref="Vector4F"/> representing the vector specified by <paramref name="value"/>. /// </param> /// <returns><see langword="true"/> if value was converted successfully; otherwise, <see langword="false"/>.</returns> public static bool TryParse(string value, out Vector4F result) { Regex r = new Regex(@"\((?<x>.*),(?<y>.*),(?<z>.*),(?<w>.*)\)", RegexOptions.Singleline); Match m = r.Match(value); if (m.Success) { result = new Vector4F( float.Parse(m.Result("${x}")), float.Parse(m.Result("${y}")), float.Parse(m.Result("${z}")), float.Parse(m.Result("${w}")) ); return(true); } result = Vector4F.Zero; return(false); }
public virtual Vector3F getScreenWorldLocation(int x,int y,View view) { this.doUpdate(view.RenderSystem); int w = view.RenderWindow.getWidth(); int h = view.RenderWindow.getHeight(); Vector4F vec = new Vector4F(); vec.X = m_view_param.NearDist * (((2.0f * x) / w) - 1.0f); vec.Y = m_view_param.NearDist * (((2.0f * (h - y)) / h) - 1.0f); vec.Z = 0.0f; vec.W = m_view_param.NearDist; Matrix4F vpInverse = (m_projmat * m_viewmat).Inverse(); vec = vpInverse * vec; vec /= vec.W; return new Vector3F(vec.X, vec.Y, vec.Z); }
/// <summary> /// Initializes a new instance of the <see cref="Vector4F"/> class using coordinates from a given <see cref="Vector4F"/> instance. /// </summary> /// <param name="vector">A <see cref="Vector4F"/> to get the coordinates from.</param> public Vector4F(Vector4F vector) { _x = vector.X; _y = vector.Y; _z = vector.Z; _w = vector.W; }
/// <summary> /// Calculates the dot product of two vectors. /// </summary> /// <param name="left">A <see cref="Vector4F"/> instance.</param> /// <param name="right">A <see cref="Vector4F"/> instance.</param> /// <returns>The dot product value.</returns> public static float DotProduct(Vector4F left, Vector4F right) { return (left.X * right.X) + (left.Y * right.Y) + (left.Z * right.Z) + (left.W * right.W); }
/// <summary> /// Divides a vector by a scalar. /// </summary> /// <param name="vector">A <see cref="Vector4F"/> instance.</param> /// <param name="scalar">A scalar</param> /// <param name="result">A <see cref="Vector4F"/> instance to hold the result.</param> /// <remarks> /// result[i] = vector[i] / scalar /// </remarks> public static void Divide(Vector4F vector, float scalar, ref Vector4F result) { result.X = vector.X / scalar; result.Y = vector.Y / scalar; result.Z = vector.Z / scalar; result.W = vector.W / scalar; }
/// <summary> /// Divides a vector by another vector. /// </summary> /// <param name="left">A <see cref="Vector4F"/> instance.</param> /// <param name="right">A <see cref="Vector4F"/> instance.</param> /// <returns>A new <see cref="Vector4F"/> containing the quotient.</returns> /// <remarks> /// result[i] = left[i] / right[i]. /// </remarks> public static Vector4F Divide(Vector4F left, Vector4F right) { return new Vector4F(left.X / right.X, left.Y / right.Y, left.Z / right.Z, left.W / right.W); }
/// <summary> /// Subtracts a vector from a scalar. /// </summary> /// <param name="vector">A <see cref="Vector4F"/> instance.</param> /// <param name="scalar">A single-precision floating-point number.</param> /// <returns>A new <see cref="Vector4F"/> instance containing the difference.</returns> /// <remarks> /// result[i] = scalar - vector[i] /// </remarks> public static Vector4F Subtract(float scalar, Vector4F vector) { return new Vector4F(scalar - vector.X, scalar - vector.Y, scalar - vector.Z, scalar - vector.W); }
/// <summary> /// Adds two vectors and put the result in the third vector. /// </summary> /// <param name="left">A <see cref="Vector4F"/> instance.</param> /// <param name="right">A <see cref="Vector4F"/> instance</param> /// <param name="result">A <see cref="Vector4F"/> instance to hold the result.</param> public static void Add(Vector4F left, Vector4F right, ref Vector4F result) { result.X = left.X + right.X; result.Y = left.Y + right.Y; result.Z = left.Z + right.Z; result.W = left.W + right.W; }
/// <summary> /// Divides a vector by a scalar. /// </summary> /// <param name="vector">A <see cref="Vector4F"/> instance.</param> /// <param name="scalar">A scalar</param> /// <returns>A new <see cref="Vector4F"/> containing the quotient.</returns> /// <remarks> /// result[i] = vector[i] / scalar; /// </remarks> public static Vector4F operator /(Vector4F vector, float scalar) { return(Vector4F.Divide(vector, scalar)); }
/// <summary> /// Multiplies a vector by a scalar. /// </summary> /// <param name="vector">A <see cref="Vector4F"/> instance.</param> /// <param name="scalar">A single-precision floating-point number.</param> /// <returns>A new <see cref="Vector4F"/> containing the result.</returns> public static Vector4F operator *(float scalar, Vector4F vector) { return(Vector4F.Multiply(vector, scalar)); }
/// <summary> /// Subtracts a vector from a scalar. /// </summary> /// <param name="vector">A <see cref="Vector4F"/> instance.</param> /// <param name="scalar">A single-precision floating-point number.</param> /// <returns>A new <see cref="Vector4F"/> instance containing the difference.</returns> /// <remarks> /// result[i] = scalar - vector[i] /// </remarks> public static Vector4F operator -(float scalar, Vector4F vector) { return(Vector4F.Subtract(scalar, vector)); }
/// <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> /// Adds two vectors. /// </summary> /// <param name="left">A <see cref="Vector4F"/> instance.</param> /// <param name="right">A <see cref="Vector4F"/> instance.</param> /// <returns>A new <see cref="Vector4F"/> instance containing the sum.</returns> public static Vector4F Add(Vector4F left, Vector4F right) { return new Vector4F(left.X + right.X, left.Y + right.Y, left.Z + right.Z, left.W + right.W); }
/// <summary> /// Divides a scalar by a vector. /// </summary> /// <param name="vector">A <see cref="Vector4F"/> instance.</param> /// <param name="scalar">A scalar</param> /// <returns>A new <see cref="Vector4F"/> containing the quotient.</returns> /// <remarks> /// result[i] = scalar / vector[i] /// </remarks> public static Vector4F operator /(float scalar, Vector4F vector) { return(Vector4F.Divide(scalar, vector)); }
/// <summary> /// Subtracts a vector from a vector. /// </summary> /// <param name="left">A <see cref="Vector4F"/> instance.</param> /// <param name="right">A <see cref="Vector4F"/> instance.</param> /// <returns>A new <see cref="Vector4F"/> instance containing the difference.</returns> /// <remarks> /// result[i] = left[i] - right[i]. /// </remarks> public static Vector4F Subtract(Vector4F left, Vector4F right) { return new Vector4F(left.X - right.X, left.Y - right.Y, left.Z - right.Z, left.W - right.W); }
/// <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="Vector3F"/> instance.</param> /// <param name="result">A <see cref="Vector3F"/> instance to hold the result.</param> public static void Transform(Matrix4F matrix, Vector4F vector, ref Vector3F result) { result.X = (matrix.M11 * vector.X) + (matrix.M12 * vector.Y) + (matrix.M13 * vector.Z) + matrix.M14; result.Y = (matrix.M21 * vector.X) + (matrix.M22 * vector.Y) + (matrix.M23 * vector.Z) + matrix.M24; result.Z = (matrix.M31 * vector.X) + (matrix.M32 * vector.Y) + (matrix.M33 * vector.Z) + matrix.M34; }
/// <summary> /// Subtracts a vector from a scalar and put the result into another vector. /// </summary> /// <param name="vector">A <see cref="Vector4F"/> instance.</param> /// <param name="scalar">A single-precision floating-point number.</param> /// <param name="result">A <see cref="Vector4F"/> instance to hold the result.</param> /// <remarks> /// result[i] = vector[i] - scalar /// </remarks> public static void Subtract(Vector4F vector, float scalar, ref Vector4F result) { result.X = vector.X - scalar; result.Y = vector.Y - scalar; result.Z = vector.Z - scalar; result.W = vector.W - scalar; }
HandleResult Camera3DController_OnRightDraging(Point location, Point delta) { Vector3F lookatpt = m_current_view.getCamera().Direction; Vector3F postiton = m_current_view.getCamera().Position; Vector3F dir = lookatpt - postiton; Vector3F top = MathHelper.IsZero(dir.X) && MathHelper.IsZero(dir.Y) ? Vector3F.YAxis : Vector3F.ZAxis; Vector3F right = Vector3F.CrossProduct(dir, top); right.Normalize(); Vector3F up = Vector3F.CrossProduct(right, dir); up.Normalize(); QuaternionF q1 = QuaternionF.FromAxisAngle(right, delta.Y * -1.0f * m_rotate_speed); QuaternionF q2 = QuaternionF.FromAxisAngle(up, delta.X * -1.0f * m_rotate_speed); q1.Normalize(); q2.Normalize(); QuaternionF q = q1 * q2; q.Normalize(); Matrix4F m = QuaternionF.QuaternionToMatrix(q); Vector4F v_rotate = new Vector4F(dir.X, dir.Y, dir.Z, 0); v_rotate = m * v_rotate; dir = new Vector3F(v_rotate.X, v_rotate.Y, v_rotate.Z); if (Focus || m_current_view.getCamera().Focus) m_current_view.getCamera().Position = lookatpt - dir; else m_current_view.getCamera().Direction = postiton + dir; return HandleResult.Done; }
/// <summary> /// Divides a scalar by a vector. /// </summary> /// <param name="vector">A <see cref="Vector4F"/> instance.</param> /// <param name="scalar">A scalar</param> /// <returns>A new <see cref="Vector4F"/> containing the quotient.</returns> /// <remarks> /// result[i] = scalar / vector[i] /// </remarks> public static Vector4F Divide(float scalar, Vector4F vector) { return new Vector4F(scalar / vector.X, scalar / vector.Y, scalar / vector.Z, scalar / vector.W); }
/// <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)); }
/// <summary> /// Multiplies a vector by a scalar. /// </summary> /// <param name="vector">A <see cref="Vector4F"/> instance.</param> /// <param name="scalar">A single-precision floating-point number.</param> /// <returns>A new <see cref="Vector4F"/> containing the result.</returns> public static Vector4F Multiply(Vector4F vector, float scalar) { return new Vector4F(vector.X * scalar, vector.Y * scalar, vector.Z * scalar, vector.W * scalar); }
/// <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)); }
/// <summary> /// Tests whether two vectors are approximately equal using default tolerance value. /// </summary> /// <param name="left">A <see cref="Vector4F"/> instance.</param> /// <param name="right">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 left, Vector4F right) { return ApproxEqual(left, right, MathFunctions.EpsilonF); }
/// <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)); }
/// <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> /// 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)); }
/// <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)); }
/// <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)); }
/// <summary> /// Converts the specified string to its <see cref="Vector4F"/> equivalent. /// A return value indicates whether the conversion succeeded or failed. /// </summary> /// <param name="value">A string representation of a <see cref="Vector4F"/>.</param> /// <param name="result"> /// When this method returns, if the conversion succeeded, /// contains a <see cref="Vector4F"/> representing the vector specified by <paramref name="value"/>. /// </param> /// <returns><see langword="true"/> if value was converted successfully; otherwise, <see langword="false"/>.</returns> public static bool TryParse(string value, out Vector4F result) { Regex r = new Regex(@"\((?<x>.*),(?<y>.*),(?<z>.*),(?<w>.*)\)", RegexOptions.Singleline); Match m = r.Match(value); if (m.Success) { result = new Vector4F( float.Parse(m.Result("${x}")), float.Parse(m.Result("${y}")), float.Parse(m.Result("${z}")), float.Parse(m.Result("${w}")) ); return true; } result = Vector4F.Zero; return false; }
/// <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> /// Adds a vector and a scalar. /// </summary> /// <param name="vector">A <see cref="Vector4F"/> instance.</param> /// <param name="scalar">A single-precision floating-point number.</param> /// <returns>A new <see cref="Vector4F"/> instance containing the sum.</returns> public static Vector4F Add(Vector4F vector, float scalar) { return new Vector4F(vector.X + scalar, vector.Y + scalar, vector.Z + scalar, vector.W + scalar); }
/// <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)); }
/// <summary> /// Adds a vector and a scalar and put the result into another vector. /// </summary> /// <param name="vector">A <see cref="Vector4F"/> instance.</param> /// <param name="scalar">A single-precision floating-point number.</param> /// <param name="result">A <see cref="Vector4F"/> instance to hold the result.</param> public static void Add(Vector4F vector, float scalar, ref Vector4F result) { result.X = vector.X + scalar; result.Y = vector.Y + scalar; result.Z = vector.Z + scalar; result.W = vector.W + scalar; }
/// <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)); }
/// <summary> /// Subtracts a scalar from a vector. /// </summary> /// <param name="vector">A <see cref="Vector4F"/> instance.</param> /// <param name="scalar">A single-precision floating-point number.</param> /// <returns>A new <see cref="Vector4F"/> instance containing the difference.</returns> /// <remarks> /// result[i] = vector[i] - scalar /// </remarks> public static Vector4F Subtract(Vector4F vector, float scalar) { return new Vector4F(vector.X - scalar, vector.Y - scalar, vector.Z - scalar, vector.W - scalar); }
/// <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)); }
/// <summary> /// Subtracts a vector from a second vector and puts the result into a third vector. /// </summary> /// <param name="left">A <see cref="Vector4F"/> instance.</param> /// <param name="right">A <see cref="Vector4F"/> instance</param> /// <param name="result">A <see cref="Vector4F"/> instance to hold the result.</param> /// <remarks> /// result[i] = left[i] - right[i]. /// </remarks> public static void Subtract(Vector4F left, Vector4F right, ref Vector4F result) { result.X = left.X - right.X; result.Y = left.Y - right.Y; result.Z = left.Z - right.Z; result.W = left.W - right.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 DotProduct(Vector4F u, Vector4F v) { return((u.X * v.X) + (u.Y * v.Y) + (u.Z * v.Z) + (u.W * v.W)); }
/// <summary> /// Subtracts a scalar from a vector and put the result into another vector. /// </summary> /// <param name="vector">A <see cref="Vector4F"/> instance.</param> /// <param name="scalar">A single-precision floating-point number.</param> /// <param name="result">A <see cref="Vector4F"/> instance to hold the result.</param> /// <remarks> /// result[i] = scalar - vector[i] /// </remarks> public static void Subtract(float scalar, Vector4F vector, ref Vector4F result) { result.X = scalar - vector.X; result.Y = scalar - vector.Y; result.Z = scalar - vector.Z; result.W = scalar - vector.W; }
/// <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)); }
/// <summary> /// Divides a vector by a scalar. /// </summary> /// <param name="vector">A <see cref="Vector4F"/> instance.</param> /// <param name="scalar">A scalar</param> /// <returns>A new <see cref="Vector4F"/> containing the quotient.</returns> /// <remarks> /// result[i] = vector[i] / scalar; /// </remarks> public static Vector4F Divide(Vector4F vector, float scalar) { return new Vector4F(vector.X / scalar, vector.Y / scalar, vector.Z / scalar, vector.W / scalar); }
/// <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>True if the two vectors are approximately equal; otherwise, False.</returns> public static bool ApproxEqual(Vector4F v, Vector4F u) { return(ApproxEqual(v, u, MathFunctions.EpsilonF)); }
/// <summary> /// Divides a vector by another vector. /// </summary> /// <param name="left">A <see cref="Vector4F"/> instance.</param> /// <param name="right">A <see cref="Vector4F"/> instance.</param> /// <param name="result">A <see cref="Vector4F"/> instance to hold the result.</param> /// <remarks> /// result[i] = left[i] / right[i] /// </remarks> public static void Divide(Vector4F left, Vector4F right, ref Vector4F result) { result.X = left.X / right.X; result.Y = left.Y / right.Y; result.Z = left.Z / right.Z; result.W = left.W / right.W; }
/// <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)); }
/// <summary> /// Divides a scalar by a vector. /// </summary> /// <param name="vector">A <see cref="Vector4F"/> instance.</param> /// <param name="scalar">A scalar</param> /// <param name="result">A <see cref="Vector4F"/> instance to hold the result.</param> /// <remarks> /// result[i] = scalar / vector[i] /// </remarks> public static void Divide(float scalar, Vector4F vector, ref Vector4F result) { result.X = scalar / vector.X; result.Y = scalar / vector.Y; result.Z = scalar / vector.Z; result.W = scalar / 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> /// Multiplies a vector by a scalar and put the result in another vector. /// </summary> /// <param name="vector">A <see cref="Vector4F"/> instance.</param> /// <param name="scalar">A single-precision floating-point number.</param> /// <param name="result">A <see cref="Vector4F"/> instance to hold the result.</param> public static void Multiply(Vector4F vector, float scalar, ref Vector4F result) { result.X = vector.X * scalar; result.Y = vector.Y * scalar; result.Z = vector.Z * scalar; result.W = vector.W * scalar; }
/// <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)); }
/// <summary> /// Negates a vector. /// </summary> /// <param name="vector">A <see cref="Vector4F"/> instance.</param> /// <returns>A new <see cref="Vector4F"/> instance containing the negated values.</returns> public static Vector4F Negate(Vector4F vector) { return new Vector4F(-vector.X, -vector.Y, -vector.Z, -vector.W); }
/// <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)); }
/// <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)); }
/// <summary> /// Initializes a new instance of the <see cref="Matrix4F"/> structure with the specified values. /// </summary> /// <param name="column1">A <see cref="Vector4F"/> instance holding values for the first column.</param> /// <param name="column2">A <see cref="Vector4F"/> instance holding values for the second column.</param> /// <param name="column3">A <see cref="Vector4F"/> instance holding values for the third column.</param> /// <param name="column4">A <see cref="Vector4F"/> 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; }
/// <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> /// 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); }
/// <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)); }