/// <summary> /// Rotates this by "a" degrees and returns the result /// </summary> /// <param name="degrees"></param> /// <param name="result"></param> /// <returns></returns> public JJVector rotate(double degrees, JJVector result) { result.set(this); result.rotateSelf(degrees); return(result); }
/// <summary> /// returns the distance beteween the two vectors. Will always be positive.Same as minus(v).mag(). /// </summary> /// <param name="v"></param> /// <returns></returns> // Useful Functions public double dist(JJVector v) { var dx = mX - v.x(); var dy = mY - v.y(); return(Math.Sqrt(dx * dx + dy * dy)); }
/// <summary> /// Computes the velocity vector, which is just the vector pointing /// in the same direction as "this", but with both time and distance /// scaled, such that result.t() == 1. (See below for the /// usefulness of the second form.) /// </summary> /// <param name="result"></param> /// <returns></returns> public JJVector velocity(JJVector result) { mult(1.0d / mT, result); result.set_t(1.0); return(result); }
public static JJVector Polar(double r, double a, double t) { JJVector pR = new JJVector(r, 0, t); pR.rotateSelf(a); return(pR); }
public void set(JJVector v) => set(v.mX, v.mY, v.mT);
public JJVector(JJVector v) : this(v.mX, v.mY, v.mT) { }
/// <summary> /// returns the "unit-ised" vector of this. This function works in the same way as plus, minus and mult. /// </summary> /// <param name="result"></param> /// <returns></returns> public JJVector unit(JJVector result) { var invMag = 1.0d / mag(); return(mult(invMag, result)); }
public JJVector mult(double k, JJVector result) { result.set(mX * k, mY * k, mT * k); return(result); }
public JJVector minus(JJVector v) { return(minus(v, new JJVector())); }
public JJVector minus(JJVector v, JJVector result) { result.set(mX - v.x(), mY - v.y(), mT - v.t()); return(result); }
public JJVector plus(JJVector v) { return(plus(v, new JJVector())); }
public JJVector plus(JJVector v, JJVector result) { result.set(mX + v.x(), mY + v.y(), mT + v.t()); return(result); }
/// <summary> /// /// </summary> /// <param name="v"></param> /// <returns>returns this . v, i.e. the dot product of this and v.</returns> public double dot(JJVector v) => mX *v.x() + mY * v.y();