private Tuple <int, int> getIndices(SimpleProjectile proj1, SimpleProjectile proj2) { int index1 = projectiles.IndexOf(proj1); int index2 = projectiles.IndexOf(proj2); return(new Tuple <int, int>(index1, index2)); }
public Connector(SimpleProjectile proj1, SimpleProjectile proj2, double springConstant, double breakingForce) { Projectile1 = proj1; Projectile2 = proj2; unstretchedLength = (proj1.Position - proj2.Position).Length; this.springConstant = springConstant; this.breakingForce = breakingForce; }
private SimpleProjectile findParticle(Vector3D position) { double minDistance = double.MaxValue; SimpleProjectile projectile = null; foreach (var proj in structure.Projectiles) { double distance = (position - proj.Position).LengthSquared; if (distance < minDistance) { minDistance = distance; projectile = proj; } } return(projectile); }
public void AddConnector(SimpleProjectile proj1, SimpleProjectile proj2, double springConstant, double breakingForce = Double.MaxValue) { if (proj1 == proj2) { return; } foreach (var con in connectors) { if ((con.Projectile1 == proj1 && con.Projectile2 == proj2) || (con.Projectile1 == proj2 && con.Projectile2 == proj1)) { return; // This returns without error because I suspect people would like that behavior } } connectors.Add(new Connector(proj1, proj2, springConstant, breakingForce)); }
public Truss() { //Make right grounding //Make left grounding //Make inner rope bridge projectile for (int x = 10; x >= 0; x = x - 1) { var proj = new SimpleProjectile(new Vector3D(x, 0, 4 * x * x + 5), new Vector3D(0, 0, 0), 1); AddProjectile(proj); } for (int x = 10; x >= 0; x = x - 1) { var proj = new SimpleProjectile(new Vector3D(x, 0, 4 * x * x + 4), new Vector3D(0, 0, 0), 1); } //Make outer rope bridge projectile //Make connectors }
private void addGroundForce(SimpleProjectile proj, double timeIncrement) { if (LockGround) { proj.Velocity = new Vector3D(0, 0, 0); proj.Position = new Vector3D(proj.Position.X, proj.Position.Y, 0); proj.AddForce(-proj.Forces); } else { proj.Velocity = new Vector3D(proj.Velocity.X, proj.Velocity.Y, 0); proj.Position = new Vector3D(proj.Position.X, proj.Position.Y, 0); double forceZ = proj.Forces.Z; if (forceZ < 0) { proj.AddForce(new Vector3D(0, 0, -forceZ)); } } }
protected void addConnector(SimpleProjectile proj1, SimpleProjectile proj2) { structure.AddConnector(proj1, proj2, springConst, breakingForce); }
protected void addProjectile(SimpleProjectile proj) { proj.Velocity = new Vector3D(0, 0, 0); structure.AddProjectile(proj); }
public void AddProjectile(SimpleProjectile proj) { projectiles.Add(proj); }