Example #1
0
        public static FDGVector2 operator /(float a, FDGVector2 b)
        {
            FDGVector2 temp = new FDGVector2(b.x, b.y);

            temp.Divide(a);
            return(temp);
        }
Example #2
0
        public static FDGVector2 operator *(float a, FDGVector2 b)
        {
            FDGVector2 temp = new FDGVector2(b.x, b.y);

            temp.Multiply(a);
            return(temp);
        }
Example #3
0
        public static FDGVector2 operator /(FDGVector2 a, float b)
        {
            FDGVector2 temp = new FDGVector2(a.x, a.y);

            temp.Divide(b);
            return(temp);
        }
Example #4
0
        public static FDGVector2 operator *(FDGVector2 a, float b)
        {
            FDGVector2 temp = new FDGVector2(a.x, a.y);

            temp.Multiply(b);
            return(temp);
        }
Example #5
0
        public static FDGVector2 operator -(FDGVector2 a, FDGVector2 b)
        {
            FDGVector2 temp = new FDGVector2(a.x, a.y);

            temp.Subtract(b);
            return(temp);
        }
Example #6
0
        public static FDGVector2 operator +(FDGVector2 a, FDGVector2 b)
        {
            FDGVector2 temp = new FDGVector2(a.x, a.y);

            temp.Add(b);
            return(temp);
        }
Example #7
0
        public static AbstractVector Random()
        {
            Random     random = new Random();
            FDGVector2 retVec = new FDGVector2(10.0f * (RandomFloat() - 0.5f), 10.0f * (RandomFloat() - 0.5f));

            return(retVec);
        }
Example #8
0
        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);
        }
Example #9
0
        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);
        }
Example #10
0
        public override AbstractVector Subtract(AbstractVector v2)
        {
            FDGVector2 v22 = v2 as FDGVector2;

            x = x - v22.x;
            y = y - v22.y;
            return(this);
        }
Example #11
0
        public override AbstractVector Add(AbstractVector v2)
        {
            FDGVector2 v22 = v2 as FDGVector2;

            x = x + v22.x;
            y = y + v22.y;
            return(this);
        }
Example #12
0
        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));
        }
Example #13
0
        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));
        }
Example #14
0
        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;
        }
Example #15
0
        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;
                    }
                }
            }
        }