コード例 #1
0
        /*
         * 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));
        }
コード例 #2
0
        /*
         * 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);
        }
コード例 #3
0
 public static double LengthSQ(Vector2D p)
 {
     return(p.GetLength() * p.GetLength());
 }
コード例 #4
0
        /*
         * 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());
        }