public static void gameStart() { Instance.Create(new Background { Color = Colors.LightGray }); GlobalEvent.ExitOnEscape = true; View.Rectangle(-1, 1, 2, -2).Bind(); diagram = Instance <SpacetimeDiagram> .Create(); stringModel = new StringModel(Observer.Default.Origin.ProperOffset(-0.8, 0), 0.631, 0, 0, 0.45); diagram.Elements.Add(stringModel); var(l, r) = stringModel.Fragment(0.6, 2.5, 2.5); diagram.Elements.Add(l); diagram.Elements.Add(r); // //(l, r) = r.Fragment(0.45, 1, 1); //diagram.Elements.Add(l); //diagram.Elements.Add(r); var rnd = new Random(); // for (int i = 0; i < 10; i++) // diagram.Elements.Add(new SpacetimeEvent(Observer.Default.Point(rnd.NextDouble() - 0.5, rnd.NextDouble() - 0.5))); GlobalEvent.BeginStep += GlobalEvent_BeginStep; }
public (StringModel, StringModel) Fragment(double z, double leftLifetime, double rightLifetime) { if (z <= 0 || z >= 1) { throw new ArgumentOutOfRangeException(nameof(z)); } var leftOffset = _leftZ(Lifetime); var rightOffset = _rightZ(Lifetime); var Et = rightOffset - leftOffset; var center = (leftOffset + rightOffset) / 2.0; var q = 2 * z - 1; var left = new StringModel(Origin.ProperOffset(Lifetime, center + Et / 2 * (q - 1) / 2), z * Et, _leftP(Lifetime), 0, leftLifetime); var right = new StringModel(Origin.ProperOffset(Lifetime, center + Et / 2 * (q + 1) / 2), (1 - z) * Et, 0, _rightP(Lifetime), rightLifetime); return(left, right); }