public void ApplyGravity(Moon moon) { if (moon.x > this.x) { this.dx += 1; } if (moon.x < this.x) { this.dx -= 1; } if (moon.y > this.y) { this.dy += 1; } if (moon.y < this.y) { this.dy -= 1; } if (moon.z > this.z) { this.dz += 1; } if (moon.z < this.z) { this.dz -= 1; } }
public void ComputeVelocities(Moon other) { int dx = other.Position.X.CompareTo(Position.X); int dy = other.Position.Y.CompareTo(Position.Y); int dz = other.Position.Z.CompareTo(Position.Z); var dV = new Vector3(dx, dy, dz); Velocity += dV; other.Velocity += -dV; }
private void WriteMoon(Moon m) { Console.WriteLine($"pos=<x={m.x.ToString(" 000;-000; 0")}, y={m.y.ToString(" 000;-000; 0")}, z={m.z.ToString(" 000;-000; 0")}> vel=<x={m.dx.ToString(" 000;-000; 0")}, y={m.dy.ToString(" 000;-000; 0")}, z={m.dz.ToString(" 000;-000; 0")}>"); }
public bool Equals(Moon obj) { return(this.x == obj.x && this.y == obj.y && this.z == obj.z && this.dx == obj.dx && this.dy == obj.dy && this.dz == obj.dz); }