public void MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button.HasFlag(System.Windows.Forms.MouseButtons.Left)) leftButton = true; if (e.Button.HasFlag(System.Windows.Forms.MouseButtons.Right)) rightButton = true; mousePos = new int2(e.X, e.Y); dragStart = new int2(e.X, e.Y); UpdateMouseControls(); }
public void MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { mousePos = new int2(e.X, e.Y); UpdateMouseControls(); dragStart = new int2(e.X, e.Y); }
public double2(int2 i) { x = (double)i.x; y = (double)i.y; }
public void SetUndefined() { m_min = new int2(int.MaxValue, int.MaxValue); m_max = new int2(int.MinValue, int.MinValue); }
public float2(int2 i) { x = (float)i.x; y = (float)i.y; }
public void Intersection(BoxI2 box) { if (!Intersects(box)) { SetUndefined(); return; } m_min = m_min.Max(box.m_min); m_max = m_max.Min(box.m_max); }
public void MergePoint(int2 point1) { m_min = m_min.Min(point1); m_max = m_max.Max(point1); }
public BoxI2(Box2 b) { m_min = new int2(b.Min); m_max = new int2(b.Max); }
public bool Contains(int2 point) { if (!IsDefined()) return false; if (m_min.x > point.x) return false; if (m_min.y > point.y) return false; if (m_max.x < point.x) return false; if (m_max.y < point.y) return false; return true; }
public int2 Min(int2 v) { int2 ret = new int2(); ret.x = x < v.x ? x : v.x; ret.y = y < v.y ? y : v.y; return ret; }
public BoxI2(int2 min, int2 max) { m_min = min.Min(max); m_max = min.Max(max); }
public int2 Max(int2 v) { int2 ret = new int2(); ret.x = x > v.x ? x : v.x; ret.y = y > v.y ? y : v.y; return ret; }
// math functions public int Dot(int2 v) { return (x * v.x) + (y * v.y); }
public int Distance(int2 v) { int2 delta = v - this; int len = delta.Dot(delta); return (int)System.Math.Sqrt((double)len); }
public static int2 Lerp(int2 a, int2 b, int alpha) { throw new Exception("Not yet implemented"); }
public int2(int2 f) { x = f.x; y = f.y; }