public void removeLink(Link link) { links.Remove(link); }
public void bounceFixed(Link link) { Point pa = new Point(link.A.positionX, link.A.positionY); Point pb = new Point(link.B.positionX, link.B.positionY); Transform tf = new Transform(pa, pb); Point poldt = tf.transform(new Point(oldx, oldy)); Point pnewt = tf.transform(new Point(newx, newy)); if (poldt.y * pnewt.y < 0) { Point pbt = tf.transform(pb); double newFraction = ( -poldt.y) / (pnewt.y - poldt.y); if (newFraction < fraction) { double x = (1 - newFraction) * poldt.x + pnewt.x * newFraction; if (x >= 0 && x <= pbt.x) { fraction = newFraction; double y; if (poldt.y < 0) y = -1e-3; else y = 1e-3; Point pn = tf.inverse(new Point(x, y)); positionX = pn.x; positionY = pn.y; Point vt = tf.transformVector(new Point(newvx, newvy)); vt.y = model.surfaceReflection * vt.y; vt.x = model.surfaceFriction * vt.x; Point vn = tf.inverseVector(vt); velocityX = vn.x; velocityY = vn.y; } } } }
public void addLink(Link link) { links.Add(link); }