/// <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> /// 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> /// 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> /// Adds the specified vector to this vector. /// </summary> /// <remarks> /// This vector is <b>modified</b>. /// </remarks> /// /// <param name="x">x coordinate of the vector to add</param> /// <param name="y">y coordinate of the vector to add</param> /// <param name="z">z coordinate of the vector to add</param> /// <returns>this vector</returns> /// public static IModifiableVector3d add(this IModifiableVector3d vector, double x, double y, double z) { vector.setX(vector.x() + x); vector.setX(vector.y() + y); vector.setX(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); }
/// <summary> /// Sets the <c>z</c> component of this vector. /// </summary> /// /// <param name="z">component to set</param> /// public static void setZ(this IModifiableVector3d vector, double z) { vector.set(2, z); }
/// <summary> /// Sets the <c>y</c> component of this vector. /// </summary> /// /// <param name="y">component to set</param> /// public static void setY(this IModifiableVector3d vector, double y) { vector.set(1, y); }
/// <summary> /// Sets the <c>x</c> component of this vector. /// </summary> /// /// <param name="x">component to set</param> /// public static void setX(this IModifiableVector3d vector, double x) { vector.set(0, x); }
/// <summary> /// Normalizes this vector with length <c>1</c>. /// </summary> /// <remarks> /// This vector is <b>modified</b>. /// </remarks> /// /// <returns>this vector</returns> /// public static IModifiableVector3d normalize(this IModifiableVector3d vector) { return(vector.divide(vector.magnitude())); }
/// <summary> /// Negates this vector. /// </summary> /// <remarks> /// This vector is <b>modified</b>. /// </remarks> /// /// <returns>this vector</returns> /// public static IModifiableVector3d negate(this IModifiableVector3d vector) { return(vector.multiply(-1.0)); }