/// <summary> Returns the (4-space) angle in radians between this vector and /// the vector parameter; the return value is constrained to the /// range [0,PI]. /// </summary> /// <param name="v1"> the other vector /// </param> /// <returns> the angle in radians in the range [0,PI] /// </returns> public double angle(Vector4d v1) { // zero div may occur. double d = dot(v1); double v1_length = v1.length(); double v_length = length(); // numerically, domain error may occur return (double) System.Math.Acos(d / v1_length / v_length); }
/// <summary> Constructs and initializes a Vector4d from the specified Vector4d.</summary> /// <param name="v1">the Vector4d containing the initialization x y z w data /// </param> public Vector4d(Vector4d v1):base(v1) { }
/// <summary> Computes the dot product of the this vector and vector v1.</summary> /// <param name="v1">the other vector /// </param> /// <returns> the dot product of this vector and vector v1 /// </returns> public double dot(Vector4d v1) { return x * v1.x + y * v1.y + z * v1.z + w * v1.w; }
/// <summary> Sets the value of this vector to the normalization of vector v1.</summary> /// <param name="v1">the un-normalized vector /// </param> public void normalize(Vector4d v1) { set_Renamed(v1); normalize(); }
/// <summary> Sets the specified column of this matrix4d to the vector provided.</summary> /// <param name="column">the column number to be modified (zero indexed) /// </param> /// <param name="v">the replacement column /// </param> public void setColumn(int column, Vector4d v) { if (column == 0) { m00 = v.x; m10 = v.y; m20 = v.z; m30 = v.w; } else if (column == 1) { m01 = v.x; m11 = v.y; m21 = v.z; m31 = v.w; } else if (column == 2) { m02 = v.x; m12 = v.y; m22 = v.z; m32 = v.w; } else if (column == 3) { m03 = v.x; m13 = v.y; m23 = v.z; m33 = v.w; } else { throw new System.IndexOutOfRangeException("column must be 0 to 3 and is " + column); } }
/// <summary> Copies the matrix values in the specified column into the /// vector parameter. /// </summary> /// <param name="column">the matrix column /// </param> /// <param name="v">The vector into which the matrix column values will be copied /// </param> public void getColumn(int column, Vector4d v) { if (column == 0) { v.x = m00; v.y = m10; v.z = m20; v.w = m30; } else if (column == 1) { v.x = m01; v.y = m11; v.z = m21; v.w = m31; } else if (column == 2) { v.x = m02; v.y = m12; v.z = m22; v.w = m32; } else if (column == 3) { v.x = m03; v.y = m13; v.z = m23; v.w = m33; } else { throw new System.IndexOutOfRangeException("column must be 0 to 3 and is " + column); } }
/// <summary> Copies the matrix values in the specified row into the /// vector parameter. /// </summary> /// <param name="row">the matrix row /// </param> /// <param name="v">The vector into which the matrix row values will be copied /// </param> public void getRow(int row, Vector4d v) { if (row == 0) { v.x = m00; v.y = m01; v.z = m02; v.w = m03; } else if (row == 1) { v.x = m10; v.y = m11; v.z = m12; v.w = m13; } else if (row == 2) { v.x = m20; v.y = m21; v.z = m22; v.w = m23; } else if (row == 3) { v.x = m30; v.y = m31; v.z = m32; v.w = m33; } else { throw new System.IndexOutOfRangeException("row must be 0 to 3 and is " + row); } }
/// <summary> Sets the specified row of this matrix4d to the Vector provided.</summary> /// <param name="row">the row number to be modified (zero indexed) /// </param> /// <param name="v">the replacement row /// </param> public void setRow(int row, Vector4d v) { if (row == 0) { m00 = v.x; m01 = v.y; m02 = v.z; m03 = v.w; } else if (row == 1) { m10 = v.x; m11 = v.y; m12 = v.z; m13 = v.w; } else if (row == 2) { m20 = v.x; m21 = v.y; m22 = v.z; m23 = v.w; } else if (row == 3) { m30 = v.x; m31 = v.y; m32 = v.z; m33 = v.w; } else { throw new System.IndexOutOfRangeException("row must be 0 to 3 and is " + row); } }
/// <summary> Constructs and initializes a Vector4d from the specified Vector4d.</summary> /// <param name="v1">the Vector4d containing the initialization x y z w data /// </param> public Vector4d(Vector4d v1) : base(v1) { }
/// <summary> Computes the dot product of the this vector and vector v1.</summary> /// <param name="v1">the other vector /// </param> /// <returns> the dot product of this vector and vector v1 /// </returns> public double dot(Vector4d v1) { return(x * v1.x + y * v1.y + z * v1.z + w * v1.w); }