示例#1
0
        /// <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);
        }
示例#2
0
        /// <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));
        }
示例#3
0
        /// <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);
        }
示例#4
0
        public static JJVector Polar(double r, double a, double t)
        {
            JJVector pR = new JJVector(r, 0, t);

            pR.rotateSelf(a);

            return(pR);
        }
示例#5
0
 public void set(JJVector v) => set(v.mX, v.mY, v.mT);
示例#6
0
 public JJVector(JJVector v) : this(v.mX, v.mY, v.mT)
 {
 }
示例#7
0
        /// <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));
        }
示例#8
0
        public JJVector mult(double k, JJVector result)
        {
            result.set(mX * k, mY * k, mT * k);

            return(result);
        }
示例#9
0
 public JJVector minus(JJVector v)
 {
     return(minus(v, new JJVector()));
 }
示例#10
0
 public JJVector minus(JJVector v, JJVector result)
 {
     result.set(mX - v.x(), mY - v.y(), mT - v.t());
     return(result);
 }
示例#11
0
 public JJVector plus(JJVector v)
 {
     return(plus(v, new JJVector()));
 }
示例#12
0
        public JJVector plus(JJVector v, JJVector result)
        {
            result.set(mX + v.x(), mY + v.y(), mT + v.t());

            return(result);
        }
示例#13
0
 /// <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();