Example #1
0
 public static double AngleBetween(Vector v1, Vector v2)
 {
     double val = Dot (v1, v2) / (v1.Length * v2.Length);
     val = Math.Acos (val);
     if (!Right (v1, v2))
         return -val;
     return val;
 }
Example #2
0
        bool DragUpdate()
        {
            if (!dragging)
                return false;

            if (!rotate) {
                return MoveWindow ();
            } else {
                Gdk.Point initial = start_root;
                Gdk.Point hot = start_hot;
                Gdk.Point win = Gdk.Point.Zero;

                hot.X += win.X;
                hot.Y += win.Y;

                initial.X -= hot.X;
                initial.Y -= hot.Y;
                Gdk.Point now = root_pos;
                now.X -= hot.X;
                now.Y -= hot.Y;

                var v1 = new Vector (initial);
                var v2 = new Vector (now);

                double angleBetween = Vector.AngleBetween (v1, v2);

                Angle = start_angle + angleBetween;
                return false;
            }
        }
Example #3
0
 public double AngleBetween(Vector v)
 {
     return AngleBetween (this, v);
 }
Example #4
0
 public static double Dot(Vector v1, Vector v2)
 {
     return v1.X * v2.X + v1.Y * v2.Y;
 }
Example #5
0
 static bool Right(Vector v1, Vector v2)
 {
     return (v1.X * v2.Y - v1.Y * v2.X) > 0;
 }