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; }
private 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; Vector v1 = new Vector (initial); Vector v2 = new Vector (now); double angle = Vector.AngleBetween (v1, v2); Angle = start_angle + angle; return false; } }
double Dot (Vector v) { return Dot (this, v); }
public static double Dot (Vector v1, Vector v2) { return v1.X * v2.X + v1.Y * v2.Y; }
static bool Right (Vector v1, Vector v2) { return (v1.X * v2.Y - v1.Y * v2.X) > 0; }
public double AngleBetween (Vector v) { return AngleBetween (this, v); }