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; }
private Node GetNode2(Node[] nodes) => nodes[NodeIndex2];
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); }
private Node GetNode1(Node[] nodes) => nodes[NodeIndex1];
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]); } }