示例#1
0
        /// <summary>
        /// Gets the X angle between two vectors
        /// </summary>
        /// <param name="vecA"></param>
        /// <returns></returns>
        public double GetAngleX()
        {
            var vx = new ASVECTOR2(1, 0);
            var vn = new ASVECTOR2(this);

            vn.Normalise();

            double angle = Math.Acos(vx.ScalarProduct(vn));

            if (vn.y < 0)
            {
                return(Math.PI * 2.0 - angle);
            }

            return(angle);
        }
示例#2
0
        /// <summary>
        /// Gets the Y angle between two vectors
        /// </summary>
        /// <param name="vecA"></param>
        /// <returns></returns>
        public double GetAngleY()
        {
            var vy = new ASVECTOR2(0, 1);
            var vn = new ASVECTOR2(this);

            vn.Normalise();

            double angle = Math.Acos(vy.ScalarProduct(vn));

            if (vn.x > 0)
            {
                return(Math.PI * 2.0 - angle);
            }

            return(angle);
        }
示例#3
0
 /// <summary>
 /// Initialise a new vector with a vector
 /// </summary>
 /// <param name="vec"></param>
 public ASVECTOR2(ASVECTOR2 vec)
 {
     this.x = vec.x;
     this.y = vec.y;
 }
示例#4
0
 /// <summary>
 /// Returns the product of vector A and B
 /// </summary>
 /// <param name="vecA"></param>
 /// <param name="vecB"></param>
 /// <returns></returns>
 public double ScalarProduct(ASVECTOR2 v)
 {
     return(this.x * v.x + this.y * v.y);
 }
示例#5
0
 /// <summary>
 /// Multiplies the x,y,z components of vectors together
 /// </summary>
 /// <param name="vecA"></param>
 /// <param name="vecB"></param>
 public void MultiplyVector(ASVECTOR2 vecB)
 {
     x *= vecB.x;
     y *= vecB.y;
 }
示例#6
0
 /// <summary>
 /// Divides the x,y,z components of two vectors by eachother
 /// </summary>
 /// <param name="vecA"></param>
 /// <param name="vecB"></param>
 public void DivideVector(ASVECTOR2 vecB)
 {
     x /= vecB.x;
     y /= vecB.y;
 }
示例#7
0
 /// <summary>
 /// Substracts the x,y,z components of two vectors from one another
 /// </summary>
 /// <param name="vecA"></param>
 /// <param name="vecB"></param>
 public void MinusFromVector(ASVECTOR2 vecB)
 {
     x -= vecB.x;
     y -= vecB.y;
 }
示例#8
0
 /// <summary>
 /// Adds the x,y,z components of two vectors together
 /// </summary>
 /// <param name="vecA"></param>
 /// <param name="vecB"></param>
 public void AddToVector(ASVECTOR2 vecB)
 {
     x += vecB.x;
     y += vecB.y;
 }