Beispiel #1
0
 /// <summary>
 /// Divides a scalar by a vector.
 /// </summary>
 /// <param name="u">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="s">A scalar</param>
 /// <param name="v">A <see cref="SLVec4f"/> instance to hold the result.</param>
 /// <remarks>
 /// m_v[i] = s / u[i]
 /// </remarks>
 public static void Divide(float s, SLVec4f u, SLVec4f v)
 {
     v.x = s / u.x;
     v.y = s / u.y;
     v.z = s / u.z;
     v.w = s / u.w;
 }
Beispiel #2
0
 /// <summary>
 /// Divides a vector by another vector.
 /// </summary>
 /// <param name="u">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="v">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="w">A <see cref="SLVec4f"/> instance to hold the result.</param>
 /// <remarks>
 /// w[i] = u[i] / m_v[i]
 /// </remarks>
 public static void Divide(SLVec4f u, SLVec4f v, SLVec4f w)
 {
     w.x = u.x / v.x;
     w.y = u.y / v.y;
     w.z = u.z / v.z;
     w.w = u.w / v.w;
 }
Beispiel #3
0
 /// <summary>
 /// Divides a vector by a scalar.
 /// </summary>
 /// <param name="u">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="s">A scalar</param>
 /// <param name="v">A <see cref="SLVec4f"/> instance to hold the result.</param>
 /// <remarks>
 /// m_v[i] = u[i] / s
 /// </remarks>
 public static void Divide(SLVec4f u, float s, SLVec4f v)
 {
     v.x = u.x / s;
     v.y = u.y / s;
     v.z = u.z / s;
     v.w = u.w / s;
 }
Beispiel #4
0
 /// <summary>
 /// Subtracts a vector from a scalar and put the result into another vector.
 /// </summary>
 /// <param name="u">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <param name="v">A <see cref="SLVec4f"/> instance to hold the result.</param>
 /// <remarks>
 /// m_v[i] = u[i] - s
 /// </remarks>
 public static void Subtract(SLVec4f u, float s, SLVec4f v)
 {
     v.x = u.x - s;
     v.y = u.y - s;
     v.z = u.z - s;
     v.w = u.w - s;
 }
Beispiel #5
0
 /// <summary>
 /// Subtracts a scalar from a vector and put the result into another vector.
 /// </summary>
 /// <param name="u">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <param name="v">A <see cref="SLVec4f"/> instance to hold the result.</param>
 /// <remarks>
 /// m_v[i] = s - u[i]
 /// </remarks>
 public static void Subtract(float s, SLVec4f u, SLVec4f v)
 {
     v.x = s - u.x;
     v.y = s - u.y;
     v.z = s - u.z;
     v.w = s - u.w;
 }
Beispiel #6
0
 /// <summary>
 /// Subtracts a vector from a second vector and puts the result into a third vector.
 /// </summary>
 /// <param name="u">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="v">A <see cref="SLVec4f"/> instance</param>
 /// <param name="w">A <see cref="SLVec4f"/> instance to hold the result.</param>
 /// <remarks>
 ///	w[i] = m_v[i] - w[i].
 /// </remarks>
 public static void Subtract(SLVec4f u, SLVec4f v, SLVec4f w)
 {
     w.x = u.x - v.x;
     w.y = u.y - v.y;
     w.z = u.z - v.z;
     w.w = u.w - v.w;
 }
Beispiel #7
0
 /// <summary>
 /// Adds a vector and a scalar and put the result into another vector.
 /// </summary>
 /// <param name="u">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <param name="v">A <see cref="SLVec4f"/> instance to hold the result.</param>
 public static void Add(SLVec4f u, float s, SLVec4f v)
 {
     v.x = u.x + s;
     v.y = u.y + s;
     v.z = u.z + s;
     v.w = u.w + s;
 }
Beispiel #8
0
 /// <summary>
 /// Adds two vectors and put the result in the third vector.
 /// </summary>
 /// <param name="u">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="v">A <see cref="SLVec4f"/> instance</param>
 /// <param name="w">A <see cref="SLVec4f"/> instance to hold the result.</param>
 public static void Add(SLVec4f u, SLVec4f v, SLVec4f w)
 {
     w.x = u.x + v.x;
     w.y = u.y + v.y;
     w.z = u.z + v.z;
     w.w = u.w + v.w;
 }
Beispiel #9
0
 /// <summary>
 /// Multiplies a vector by a scalar and put the result in another vector.
 /// </summary>
 /// <param name="u">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <param name="v">A <see cref="SLVec4f"/> instance to hold the result.</param>
 public static void Multiply(SLVec4f u, float s, SLVec4f v)
 {
     v.x = u.x * s;
     v.y = u.y * s;
     v.z = u.z * s;
     v.w = u.w * s;
 }
Beispiel #10
0
 /// <summary>
 /// Setter for all components at once
 /// </summary>
 public void Set(SLVec4f v)
 {
     x = v.x;
     y = v.y;
     z = v.z;
     w = v.w;
 }
Beispiel #11
0
 /// <summary>
 /// Post multiplies the matrix by the vector v and returns a vector.
 /// </summary>
 public SLVec4f Multiply(SLVec4f v)
 {
     return(new SLVec4f(m[0] * v.x + m[4] * v.y + m[8] * v.z + m[12] * v.w,
                        m[1] * v.x + m[5] * v.y + m[9] * v.z + m[13] * v.w,
                        m[2] * v.x + m[6] * v.y + m[10] * v.z + m[14] * v.w,
                        m[3] * v.x + m[7] * v.y + m[11] * v.z + m[15] * v.w));
 }
Beispiel #12
0
 /// <summary>
 /// Returns the cross product of this with vector v
 /// </summary>
 public SLVec4f Cross(SLVec4f v)
 {
     return(new SLVec4f(y * v.z - z * v.y,
                        z * v.x - x * v.z,
                        x * v.y - y * v.x,
                        1));
 }
Beispiel #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SLVec4f"/> class using coordinates from a given <see cref="SLVec3f"/> instance.
 /// </summary>
 /// <param name="vector">A <see cref="SLVec4f"/> to get the coordinates from.</param>
 public SLVec4f(SLVec4f vector)
 {
     this.x = vector.x;
     this.y = vector.y;
     this.z = vector.z;
     this.w = vector.w;
 }
Beispiel #14
0
 /// <summary>
 /// Calculates the cross product of two vectors.
 /// </summary>
 /// <param name="u">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="v">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="w">A <see cref="SLVec4f"/> instance to hold the cross product result.</param>
 public static void CrossProduct(SLVec4f u, SLVec4f v, SLVec4f w)
 {
     w.x = u.y * v.z - u.z * v.y;
     w.y = u.z * v.x - u.x * v.z;
     w.z = u.x * v.y - u.y * v.x;
     w.w = 1;
 }
Beispiel #15
0
 /// <summary>
 /// Calculates the cross product of two vectors.
 /// </summary>
 /// <param name="u">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="v">A <see cref="SLVec4f"/> instance.</param>
 /// <returns>A new <see cref="SLVec4f"/> containing the cross product result.</returns>
 public static SLVec4f CrossProduct(SLVec4f u, SLVec4f v)
 {
     return(new SLVec4f(
                u.y * v.z - u.z * v.y,
                u.z * v.x - u.x * v.z,
                u.x * v.y - u.y * v.x,
                1));
 }
Beispiel #16
0
 /// <summary>
 /// Returns a value indicating whether this instance is equal to
 /// the specified object.
 /// </summary>
 /// <param name="obj">An object to compare to this instance.</param>
 /// <returns>True if <paramref name="obj"/> is a <see cref="SLVec4f"/> and has the same values as this instance; otherwise, False.</returns>
 public override bool Equals(object obj)
 {
     if (obj is SLVec4f)
     {
         SLVec4f v = (SLVec4f)obj;
         return((this.x == v.x) && (this.y == v.y) && (this.z == v.z) && (this.w == v.w));
     }
     return(false);
 }
Beispiel #17
0
 /// <summary>
 /// Tests whether two vectors are approximately equal given a tolerance value.
 /// </summary>
 /// <param name="v">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="u">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="tolerance">The tolerance value used to test approximate equality.</param>
 /// <returns>True if the two vectors are approximately equal; otherwise, False.</returns>
 public static bool ApproxEqual(SLVec4f v, SLVec4f u, float tolerance)
 {
     return
         (
         (System.Math.Abs(v.x - u.x) <= tolerance) &&
         (System.Math.Abs(v.y - u.y) <= tolerance) &&
         (System.Math.Abs(v.z - u.z) <= tolerance) &&
         (System.Math.Abs(v.w - u.w) <= tolerance)
         );
 }
Beispiel #18
0
 /// <summary>
 /// Sets the maximum values of this and the passed vector v
 /// </summary>
 public void SetMax(SLVec4f v)
 {
     if (v.x > x)
     {
         x = v.x;
     }
     if (v.y > y)
     {
         y = v.y;
     }
     if (v.z > z)
     {
         z = v.z;
     }
     if (v.w > w)
     {
         w = v.w;
     }
 }
Beispiel #19
0
 /// <summary>
 /// Sets the minimum values of this and the passed vector v
 /// </summary>
 public void SetMin(SLVec4f v)
 {
     if (v.x < x)
     {
         x = v.x;
     }
     if (v.y < y)
     {
         y = v.y;
     }
     if (v.z < z)
     {
         z = v.z;
     }
     if (v.w < w)
     {
         w = v.w;
     }
 }
Beispiel #20
0
 /// <summary>
 /// Divides a scalar by a vector.
 /// </summary>
 /// <param name="v">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="s">A scalar</param>
 /// <returns>A new <see cref="SLVec4f"/> containing the quotient.</returns>
 /// <remarks>
 /// result[i] = s / m_v[i]
 /// </remarks>
 public static SLVec4f operator/(float s, SLVec4f v)
 {
     return(SLVec4f.Divide(s, v));
 }
Beispiel #21
0
 /// <summary>
 /// Divides a vector by a scalar.
 /// </summary>
 /// <param name="v">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="s">A scalar</param>
 /// <returns>A new <see cref="SLVec4f"/> containing the quotient.</returns>
 /// <remarks>
 /// result[i] = m_v[i] / s;
 /// </remarks>
 public static SLVec4f operator/(SLVec4f v, float s)
 {
     return(SLVec4f.Divide(v, s));
 }
Beispiel #22
0
 /// <summary>
 /// Multiplies a vector by a scalar.
 /// </summary>
 /// <param name="v">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="SLVec4f"/> containing the result.</returns>
 public static SLVec4f operator*(float s, SLVec4f v)
 {
     return(SLVec4f.Multiply(v, s));
 }
Beispiel #23
0
 /// <summary>
 /// Subtracts a vector from a scalar.
 /// </summary>
 /// <param name="v">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="SLVec4f"/> instance containing the difference.</returns>
 /// <remarks>
 /// result[i] = s - m_v[i]
 /// </remarks>
 public static SLVec4f operator-(float s, SLVec4f v)
 {
     return(SLVec4f.Subtract(s, v));
 }
Beispiel #24
0
 /// <summary>
 /// Subtracts a scalar from a vector.
 /// </summary>
 /// <param name="v">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="SLVec4f"/> instance containing the difference.</returns>
 /// <remarks>
 /// result[i] = m_v[i] - s
 /// </remarks>
 public static SLVec4f operator-(SLVec4f v, float s)
 {
     return(SLVec4f.Subtract(v, s));
 }
Beispiel #25
0
 /// <summary>
 /// Subtracts a vector from a vector.
 /// </summary>
 /// <param name="u">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="v">A <see cref="SLVec4f"/> instance.</param>
 /// <returns>A new <see cref="SLVec4f"/> instance containing the difference.</returns>
 /// <remarks>
 ///	result[i] = m_v[i] - w[i].
 /// </remarks>
 public static SLVec4f operator-(SLVec4f u, SLVec4f v)
 {
     return(SLVec4f.Subtract(u, v));
 }
Beispiel #26
0
 /// <summary>
 /// Adds a vector and a scalar.
 /// </summary>
 /// <param name="v">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="s">A scalar.</param>
 /// <returns>A new <see cref="SLVec4f"/> instance containing the sum.</returns>
 public static SLVec4f operator+(float s, SLVec4f v)
 {
     return(SLVec4f.Add(v, s));
 }
Beispiel #27
0
 /// <summary>
 /// Adds two vectors.
 /// </summary>
 /// <param name="u">A <see cref="SLVec4f"/> instance.</param>
 /// <param name="v">A <see cref="SLVec4f"/> instance.</param>
 /// <returns>A new <see cref="SLVec4f"/> instance containing the sum.</returns>
 public static SLVec4f operator+(SLVec4f u, SLVec4f v)
 {
     return(SLVec4f.Add(u, v));
 }
Beispiel #28
0
 /// <summary>
 /// Negates the values of the vector.
 /// </summary>
 /// <param name="v">A <see cref="SLVec4f"/> instance.</param>
 /// <returns>A new <see cref="SLVec4f"/> instance containing the negated values.</returns>
 public static SLVec4f operator-(SLVec4f v)
 {
     return(SLVec4f.Negate(v));
 }
Beispiel #29
0
 /// <summary>
 /// Negates a vector.
 /// </summary>
 /// <param name="v">A <see cref="SLVec3f"/> instance.</param>
 /// <returns>A new <see cref="SLVec3f"/> instance containing the negated values.</returns>
 public static SLVec4f Negate(SLVec4f v)
 {
     return(new SLVec4f(-v.x, -v.y, -v.z, -v.w));
 }
Beispiel #30
0
 /// <summary>
 /// Returns the dot product of this with vector v
 /// </summary>
 public float Dot(SLVec4f v)
 {
     return((x * v.x) + (y * v.y) + (z * v.z) + (w * v.w));
 }