public static FDGVector2 operator /(float a, FDGVector2 b) { FDGVector2 temp = new FDGVector2(b.x, b.y); temp.Divide(a); return(temp); }
public static FDGVector2 operator *(float a, FDGVector2 b) { FDGVector2 temp = new FDGVector2(b.x, b.y); temp.Multiply(a); return(temp); }
public static FDGVector2 operator /(FDGVector2 a, float b) { FDGVector2 temp = new FDGVector2(a.x, a.y); temp.Divide(b); return(temp); }
public static FDGVector2 operator *(FDGVector2 a, float b) { FDGVector2 temp = new FDGVector2(a.x, a.y); temp.Multiply(b); return(temp); }
public static FDGVector2 operator -(FDGVector2 a, FDGVector2 b) { FDGVector2 temp = new FDGVector2(a.x, a.y); temp.Subtract(b); return(temp); }
public static FDGVector2 operator +(FDGVector2 a, FDGVector2 b) { FDGVector2 temp = new FDGVector2(a.x, a.y); temp.Add(b); return(temp); }
public static AbstractVector Random() { Random random = new Random(); FDGVector2 retVec = new FDGVector2(10.0f * (RandomFloat() - 0.5f), 10.0f * (RandomFloat() - 0.5f)); return(retVec); }
public FDGVector2 ScreenToGraph(Tuple <int, int> iScreenPos) { FDGVector2 retVec = new FDGVector2(); retVec.x = (iScreenPos.Item1) - (((Width)) / 2.0f); retVec.y = (iScreenPos.Item2) - (((Height)) / 2.0f); return(retVec); }
public Tuple <int, int> GraphToScreen(FDGVector2 iPos) { var x = (int)(iPos.x + (((Width)) / 2.0f)); var y = (int)(iPos.y + (((Height)) / 2.0f)); Tuple <int, int> retPair = new Tuple <int, int>(x, y); return(retPair); }
public override AbstractVector Subtract(AbstractVector v2) { FDGVector2 v22 = v2 as FDGVector2; x = x - v22.x; y = y - v22.y; return(this); }
public override AbstractVector Add(AbstractVector v2) { FDGVector2 v22 = v2 as FDGVector2; x = x + v22.x; y = y + v22.y; return(this); }
public bool Equals(FDGVector2 p) { // If parameter is null return false: if ((object)p == null) { return(false); } // Return true if the fields match: return((x == p.x) && (y == p.y)); }
public override bool Equals(System.Object obj) { // If parameter is null return false. if (obj == null) { return(false); } // If parameter cannot be cast to Point return false. FDGVector2 p = obj as FDGVector2; if ((System.Object)p == null) { return(false); } // Return true if the fields match: return((x == p.x) && (y == p.y)); }
public GridBox(int iX, int iY, BoxType iType, string label) { InitialPosition = FDGVector2.Random() as FDGVector2; this.x = iX; this.y = iY; this.boxType = iType; switch (iType) { case BoxType.Normal: brush = new SolidBrush(Color.Black); break; case BoxType.Pinned: brush = new SolidBrush(Color.Red); break; } width = 18; height = 18; boxRec = new Rectangle(x, y, width, height); Label = label; }
private void pDrawPanel_MouseMove(object sender, MouseEventArgs e) { if (clickedNode != null) { FDGVector2 vec = m_fdgRenderer.ScreenToGraph(new Tuple <int, int>(e.Location.X, e.Location.Y)); clickedGrid.boxType = BoxType.Pinned; var fd = m_fdgRenderer.forceDirected as ForceDirected2D; var clicked = fd.graph.NodesWithGridBox.First(x => x.Key.Equals(clickedNode)); m_fdgPhysics.GetPoint(clicked).position = vec; } else { foreach (KeyValuePair <City, GridBox> keyPair in m_fdgRenderer.Boxes) { if (keyPair.Value.boxRec.IntersectsWith(new Rectangle(e.Location, new Size(1, 1)))) { keyPair.Value.boxType = BoxType.Pinned; foreach (var gridLine in m_fdgGraph.ConnectionsWithGridLines) { gridLine.Value.Highlight = false; } var path = this.m_fdgGraph.CalculateCostToNetwork(keyPair.Key, null); keyPair.Value.Cost = path.Length; foreach (var edge in path.Edges) { m_fdgGraph.ConnectionsWithGridLines[edge].Highlight = true; } } else { keyPair.Value.boxType = BoxType.Normal; } } } }