Пример #1
0
        public void Test_Add()
        {
            var pt = new ArborPoint(3, 4);

            Assert.AreEqual(3.0f, pt.X);
            Assert.AreEqual(4.0f, pt.Y);

            pt = pt.Add(new ArborPoint(10, 11));
            Assert.AreEqual(13.0f, pt.X);
            Assert.AreEqual(15.0f, pt.Y);
        }
Пример #2
0
        private void UpdateGraphBounds()
        {
            ArborPoint lt = new ArborPoint(-1.0f, -1.0f);
            ArborPoint rb = new ArborPoint(+1.0f, +1.0f);

            for (int i = 0, nodesCount = fNodes.Count; i < nodesCount; i++)
            {
                ArborPoint pt = fNodes[i].Pt;
                if (pt.IsExploded())
                {
                    continue;
                }

                if (pt.X < lt.X)
                {
                    lt.X = pt.X;
                }
                if (pt.Y < lt.Y)
                {
                    lt.Y = pt.Y;
                }
                if (pt.X > rb.X)
                {
                    rb.X = pt.X;
                }
                if (pt.Y > rb.Y)
                {
                    rb.Y = pt.Y;
                }
            }

            lt.X -= 1.2f;
            lt.Y -= 1.2f;
            rb.X += 1.2f;
            rb.Y += 1.2f;

            ArborPoint sz   = rb.Sub(lt);
            ArborPoint cent = lt.Add(sz.Div(2.0f));
            ArborPoint d    = new ArborPoint(Math.Max(sz.X, 4.0f), Math.Max(sz.Y, 4.0f)).Div(2.0f);

            fGraphBounds = new PSBounds(cent.Sub(d), cent.Add(d));
            fBHTree      = new BarnesHutTree(fGraphBounds.LeftTop, fGraphBounds.RightBottom, Theta);
        }
Пример #3
0
 internal void ApplyForce(ArborPoint a)
 {
     F = F.Add(a.Div(Mass));
 }