/// <summary> /// Adds the specified vector to this vector. /// </summary> /// <remarks> /// This vector is <b>not modified</b>. /// </remarks> /// /// <param name="v">the vector to add</param> /// <returns>this vector</returns> /// public static IModifiableVector3d add(this IModifiableVector3d vector, IVector3d v) { vector.setX(vector.x() + v.x()); vector.setY(vector.y() + v.y()); vector.setZ(vector.z() + v.z()); return(vector); }
/// <summary> /// Stores the cross product of this vector and the specified vector in this /// vector. /// </summary> /// <remarks> /// This vector is <b>modified</b>. /// </remarks> /// /// <param name="a">the vector</param> /// <returns>this vector</returns> /// public static IModifiableVector3d cross(this IModifiableVector3d vector, IVector3d a) { vector.setX(vector.y() * a.z() - vector.z() * a.y()); vector.setY(vector.z() * a.x() - vector.x() * a.z()); vector.setZ(vector.x() * a.y() - vector.y() * a.x()); return(vector); }
/// <summary> /// Devides this vector with the specified value. /// </summary> /// <remarks> /// This vector is <b>modified</b>. /// </remarks> /// /// <param name="a">the value</param> /// <returns>this vector</returns> /// public static IModifiableVector3d divide(this IModifiableVector3d vector, double a) { vector.setX(vector.x() / a); vector.setY(vector.y() / a); vector.setZ(vector.z() / a); return(vector); }
/// <summary> /// Multiplies this vector with the specified value. /// </summary> /// <remarks> /// This vector is <b>modified</b>. /// </remarks> /// /// <param name="a">the value</param> /// <returns>this vector</returns> /// public static IModifiableVector3d multiply(this IModifiableVector3d vector, double a) { vector.setX(vector.x() * a); vector.setY(vector.y() * a); vector.setZ(vector.z() * a); return(vector); }
/// <summary> /// Subtracts the specified vector from this vector. /// </summary> /// <remarks> /// This vector is <b>modified</b>. /// </remarks> /// /// <param name="x">x coordinate of the vector to subtract</param> /// <param name="y">y coordinate of the vector to subtract</param> /// <param name="z">z coordinate of the vector to subtract</param> /// <returns>this vector</returns> /// public static IModifiableVector3d subtract(this IModifiableVector3d vector, double x, double y, double z) { vector.setX(vector.x() - x); vector.setY(vector.y() - y); vector.setZ(vector.z() - z); return(vector); }
/// <summary> /// Applies this transform to the specified vector. /// </summary> /// /// <param name="vec">vector to transform</param> /// <returns>the specified vector</returns> /// public IModifiableVector3d transform(IModifiableVector3d vec) { double x, y; x = m.m00 * vec.x() + m.m01 * vec.y() + m.m02 * vec.z() + m.m03; y = m.m10 * vec.x() + m.m11 * vec.y() + m.m12 * vec.z() + m.m13; vec.setZ(m.m20 * vec.x() + m.m21 * vec.y() + m.m22 * vec.z() + m.m23); vec.setX(x); vec.setY(y); return(vec); }
/// <summary> /// Applies this transform to the specified vector. /// </summary> /// /// <param name="vec">vector to transform</param> /// <returns>the specified vector</returns> /// public IVector3d transform(IVector3d vec) { IModifiableVector3d result = vec.asModifiable(); double x, y; x = m.m00 * vec.x() + m.m01 * vec.y() + m.m02 * vec.z() + m.m03; y = m.m10 * vec.x() + m.m11 * vec.y() + m.m12 * vec.z() + m.m13; result.setZ(m.m20 * vec.x() + m.m21 * vec.y() + m.m22 * vec.z() + m.m23); result.setX(x); result.setY(y); return(result); }
/// <summary> /// Applies this transform to the specified vector. /// </summary> /// /// <param name="vec">vector to transform</param> /// <param name="amount">transform amount (0 = 0 %, 1 = 100%)</param> /// <returns>the specified vector</returns> /// public IModifiableVector3d transform(IModifiableVector3d vec, double amount) { double prevX = vec.x(); double prevY = vec.y(); double prevZ = vec.z(); double x, y; x = m.m00 * vec.x() + m.m01 * vec.y() + m.m02 * vec.z() + m.m03; y = m.m10 * vec.x() + m.m11 * vec.y() + m.m12 * vec.z() + m.m13; vec.setZ(m.m20 * vec.x() + m.m21 * vec.y() + m.m22 * vec.z() + m.m23); vec.setX(x); vec.setY(y); double diffX = vec.x() - prevX; double diffY = vec.y() - prevY; double diffZ = vec.z() - prevZ; vec.setX(prevX + (diffX) * amount); vec.setY(prevY + (diffY) * amount); vec.setZ(prevZ + (diffZ) * amount); return(vec); }