Esempio n. 1
0
        internal Vector2 GetImpulse(Node node1, Node node2)//, out bool isBroken)
        {
            var r = node1.Position - node2.Position;

            //isBroken = r.Length() > BreakLength;

            //if (isBroken)
            //    return Vector2.Zero;

            var length = r.Length();

            float displacement = length - RestLength;
            float impulse = Lambda * displacement;

            return (impulse / length) * r;
        }
Esempio n. 2
0
 private Node GetNode2(Node[] nodes) => nodes[NodeIndex2];
Esempio n. 3
0
        public void Draw(Graphics graphics, Node[] nodes)
        {
            var node1 = GetNode1(nodes);
            var node2 = GetNode2(nodes);

            graphics.DrawLine(Pens.Black, node1.Position.X, node1.Position.Y, node2.Position.X, node2.Position.Y);
        }
Esempio n. 4
0
 private Node GetNode1(Node[] nodes) => nodes[NodeIndex1];
Esempio n. 5
0
 private static void UpdateNodes(float dt, Node[] nodes, Vector2[] impulses)
 {
     for (int i = 0; i < nodes.Length; i++)
     {
         var impulse = impulses[i];
         nodes[i].Update(dt, impulse);//, previousImpulses[i]);
     }
 }