/// <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); }
/// <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); }
/// <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; }
/// <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); }
/// <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; }
/// <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; }
/// <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; }
/// <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; }