Exemple #1
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>   Calculates linear interpolation from one vector to another vector. (Just like regular lerp(), but for vectors).  </summary>
        ///
        /// <remarks>   Jan Tamis, 29-8-2017. </remarks>
        ///
        /// <param name="fromVector">   From vector. </param>
        /// <param name="toVector">     To vector. </param>
        /// <param name="atm">          The amount of interpolation; some value between 0.0 (old vector) and 1.0 (new vector). </param>
        ///
        /// <returns>   A PVector. </returns>

        public PVector lerp(PVector fromVector, PVector toVector, double atm)
        {
            if (atm > 1)
            {
                atm = 1;
            }
            else if (atm < 0)
            {
                atm = 0;
            }

            x = (float)((1 - atm) * fromVector.x + atm * toVector.x);
            y = (float)((1 - atm) * fromVector.y + atm * toVector.y);
            z = (float)((1 - atm) * fromVector.z + atm * toVector.z);

            return(this);
        }
Exemple #2
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>   Calculates linear interpolation from one vector to another vector. (Just like regular lerp(), but for vectors). </summary>
        ///
        /// <remarks>   Jan Tamis, 29-8-2017. </remarks>
        ///
        /// <param name="toVector"> The vector to chance. </param>
        /// <param name="atm">      The amount of interpolation; some value between 0.0 (old vector) and 1.0 (new vector). </param>
        ///
        /// <returns>   A PVector. </returns>

        public PVector lerp(PVector toVector, float atm)
        {
            if (atm > 1)
            {
                atm = 1;
            }
            else if (atm < 0)
            {
                atm = 0;
            }

            x = (1 - atm) * this.x + atm * toVector.x;
            y = (1 - atm) * this.y + atm * toVector.y;
            z = (1 - atm) * this.z + atm * toVector.z;

            return(this);
        }
Exemple #3
0
 public void applyForce(PVector force)
 {
     acc.add(force);
 }
Exemple #4
0
 public Particle(float x, float y)
 {
     pos = new PVector(x, y);
     vel = new PVector(0, 0);
     acc = new PVector(0, 0);
 }
Exemple #5
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>   Calculates the dot product of this vector. </summary>
        ///
        /// <remarks>   Jan Tamis, 29-8-2017. </remarks>
        ///
        /// <param name="vector">   The vector to calculate the dot product with. </param>
        ///
        /// <returns>   A float. </returns>

        public float dot(PVector vector)
        {
            return((this.x * vector.x) + (this.y * vector.y) + (this.z * vector.z));
        }
Exemple #6
0
        ///-------------------------------------------------------------------------------------------------
        /// <summary>   Calculates the Euclidean distance. </summary>
        ///
        /// <remarks>   Jan Tamis, 29-8-2017. </remarks>
        ///
        /// <param name="vector">   The vector to calculate the distance with. </param>
        ///
        /// <returns>   A float. </returns>

        public float dist(PVector vector)
        {
            return((float)(System.Math.Sqrt(System.Math.Pow(this.x - vector.x, 2) + System.Math.Pow(this.y - vector.y, 2))));
        }