/// <summary> /// Sets each component of the tuple parameter to its absolute /// value and places the modified values into this tuple. /// </summary> /// <remarks> /// Sets each component of the tuple parameter to its absolute /// value and places the modified values into this tuple. /// </remarks> /// <param name="t">the source tuple, which will not be modified</param> public void Absolute(Tuple2d t) { x = Math.Abs(t.x); y = Math.Abs(t.y); }
/// <summary> /// Sets the value of this tuple to the vector difference of /// tuple t1 and t2 (this = t1 - t2). /// </summary> /// <remarks> /// Sets the value of this tuple to the vector difference of /// tuple t1 and t2 (this = t1 - t2). /// </remarks> /// <param name="t1">the first tuple</param> /// <param name="t2">the second tuple</param> public void Sub(Tuple2d t1, Tuple2d t2) { this.x = t1.x - t2.x; this.y = t1.y - t2.y; }
/// <summary> /// Sets the value of this tuple to the vector difference of /// itself and tuple t1 (this = this - t1). /// </summary> /// <remarks> /// Sets the value of this tuple to the vector difference of /// itself and tuple t1 (this = this - t1). /// </remarks> /// <param name="t1">the other vector</param> public void Sub(Tuple2d t1) { this.x -= t1.x; this.y -= t1.y; }
/// <summary>Sets the value of this tuple to the value of the Tuple2d argument.</summary> /// <remarks>Sets the value of this tuple to the value of the Tuple2d argument.</remarks> /// <param name="t1">the tuple to be copied</param> public void Set(Tuple2d t1) { this.x = t1.x; this.y = t1.y; }
/// <summary>Constructs and initializes a Tuple2d from the specified Tuple2d.</summary> /// <remarks>Constructs and initializes a Tuple2d from the specified Tuple2d.</remarks> /// <param name="t1">the Tuple2d containing the initialization x y data</param> public Tuple2d(Tuple2d t1) { this.x = t1.x; this.y = t1.y; }
/// <summary>Sets the value of this tuple to the vector sum of itself and tuple t1.</summary> /// <remarks>Sets the value of this tuple to the vector sum of itself and tuple t1.</remarks> /// <param name="t1">the other tuple</param> public void Add(Tuple2d t1) { this.x += t1.x; this.y += t1.y; }
/// <summary> /// Sets the value of this tuple to the scalar multiplication /// of itself and then adds tuple t1 (this = s*this + t1). /// </summary> /// <remarks> /// Sets the value of this tuple to the scalar multiplication /// of itself and then adds tuple t1 (this = s*this + t1). /// </remarks> /// <param name="s">the scalar value</param> /// <param name="t1">the tuple to be added</param> public void ScaleAdd(double s, Tuple2d t1) { this.x = s * this.x + t1.x; this.y = s * this.y + t1.y; }
/// <summary> /// Linearly interpolates between this tuple and tuple t1 and /// places the result into this tuple: this = (1-alpha)*this + alpha*t1. /// </summary> /// <remarks> /// Linearly interpolates between this tuple and tuple t1 and /// places the result into this tuple: this = (1-alpha)*this + alpha*t1. /// </remarks> /// <param name="t1">the first tuple</param> /// <param name="alpha">the alpha interpolation parameter</param> public void Interpolate(Tuple2d t1, double alpha) { this.x = (1 - alpha) * this.x + alpha * t1.x; this.y = (1 - alpha) * this.y + alpha * t1.y; }
/// <summary>Sets the value of this tuple to the negation of tuple t1.</summary> /// <remarks>Sets the value of this tuple to the negation of tuple t1.</remarks> /// <param name="t1">the source vector</param> public void Negate(Tuple2d t1) { this.x = -t1.x; this.y = -t1.y; }
/// <summary> /// Returns true if the L-infinite distance between this tuple /// and tuple t1 is less than or equal to the epsilon parameter, /// otherwise returns false. /// </summary> /// <remarks> /// Returns true if the L-infinite distance between this tuple /// and tuple t1 is less than or equal to the epsilon parameter, /// otherwise returns false. The L-infinite /// distance is equal to MAX[abs(x1-x2), abs(y1-y2)]. /// </remarks> /// <param name="t1">the tuple to be compared to this tuple</param> /// <param name="epsilon">the threshold value</param> /// <returns>true or false</returns> public virtual bool EpsilonEquals(Tuple2d t1, double epsilon) { double diff; diff = x - t1.x; if (double.IsNaN(diff)) { return false; } if ((diff < 0 ? -diff : diff) > epsilon) { return false; } diff = y - t1.y; if (double.IsNaN(diff)) { return false; } if ((diff < 0 ? -diff : diff) > epsilon) { return false; } return true; }
/// <summary> /// Returns true if all of the data members of Tuple2d t1 are /// equal to the corresponding data members in this Tuple2d. /// </summary> /// <remarks> /// Returns true if all of the data members of Tuple2d t1 are /// equal to the corresponding data members in this Tuple2d. /// </remarks> /// <param name="t1">the vector with which the comparison is made</param> /// <returns>true or false</returns> public virtual bool Equals(Tuple2d t1) { try { return (this.x == t1.x && this.y == t1.y); } catch (ArgumentNullException) { return false; } }
/// <summary> /// Clamps the minimum value of the tuple parameter to the min /// parameter and places the values into this tuple. /// </summary> /// <remarks> /// Clamps the minimum value of the tuple parameter to the min /// parameter and places the values into this tuple. /// </remarks> /// <param name="min">the lowest value in the tuple after clamping</param> /// <param name="t">the source tuple, which will not be modified</param> public void ClampMin(double min, Tuple2d t) { if (t.x < min) { x = min; } else { x = t.x; } if (t.y < min) { y = min; } else { y = t.y; } }
/// <summary> /// Clamps the maximum value of the tuple parameter to the max /// parameter and places the values into this tuple. /// </summary> /// <remarks> /// Clamps the maximum value of the tuple parameter to the max /// parameter and places the values into this tuple. /// </remarks> /// <param name="max">the highest value in the tuple after clamping</param> /// <param name="t">the source tuple, which will not be modified</param> public void ClampMax(double max, Tuple2d t) { if (t.x > max) { x = max; } else { x = t.x; } if (t.y > max) { y = max; } else { y = t.y; } }
/// <summary> /// Clamps the tuple parameter to the range [low, high] and /// places the values into this tuple. /// </summary> /// <remarks> /// Clamps the tuple parameter to the range [low, high] and /// places the values into this tuple. /// </remarks> /// <param name="min">the lowest value in the tuple after clamping</param> /// <param name="max">the highest value in the tuple after clamping</param> /// <param name="t">the source tuple, which will not be modified</param> public void Clamp(double min, double max, Tuple2d t) { if (t.x > max) { x = max; } else { if (t.x < min) { x = min; } else { x = t.x; } } if (t.y > max) { y = max; } else { if (t.y < min) { y = min; } else { y = t.y; } } }
/// <summary>Constructs and initializes a Point2d from the specified Tuple2d.</summary> /// <remarks>Constructs and initializes a Point2d from the specified Tuple2d.</remarks> /// <param name="t1">the Tuple2d containing the initialization x y data</param> public Point2d(Tuple2d t1) : base(t1) { }
/// <summary> /// Sets the value of this tuple to the scalar multiplication /// of tuple t1. /// </summary> /// <remarks> /// Sets the value of this tuple to the scalar multiplication /// of tuple t1. /// </remarks> /// <param name="s">the scalar value</param> /// <param name="t1">the source tuple</param> public void Scale(double s, Tuple2d t1) { this.x = s * t1.x; this.y = s * t1.y; }
/// <summary>Constructs and initializes a Vector2f from the specified Tuple2d.</summary> /// <remarks>Constructs and initializes a Vector2f from the specified Tuple2d.</remarks> /// <param name="t1">the Tuple2d containing the initialization x y data</param> public Vector2f(Tuple2d t1) : base(t1) { }
/// <summary>Sets the value of this tuple to the vector sum of tuples t1 and t2.</summary> /// <remarks>Sets the value of this tuple to the vector sum of tuples t1 and t2.</remarks> /// <param name="t1">the first tuple</param> /// <param name="t2">the second tuple</param> public void Add(Tuple2d t1, Tuple2d t2) { this.x = t1.x + t2.x; this.y = t1.y + t2.y; }