/* * Function which returns the angle between to instances of Vector2D. */ public double GetAngleBetween(Vector2D b) { double hyp1 = this.GetLength(); double ank1 = this.x; double hyp2 = b.GetLength(); double ank2 = b.X; return(Math.Acos(ank1 / hyp1) - Math.Acos(ank2 / hyp2)); }
/* * Function which returns the angle between to instances of Vector2D. */ public double GetAngleBetween(Vector2D b) { double angle = Dot(b) / (this.GetLength() * b.GetLength()); angle = (180 / Math.PI) * Math.Acos(angle); if (Cross(b) >= 0) { angle = -angle; } return(angle); }
public static double LengthSQ(Vector2D p) { return(p.GetLength() * p.GetLength()); }
/* * Function to which calculates the Distance, between this instance and another Vector2D, as a double. */ public double GetDistance(Vector2D point) { Vector2D vector = new Vector2D(this.x - point.X, this.y - point.Y); return(vector.GetLength()); }