Model. After the Sun's pull is removed (the Sun acts almost equally on Earth and Apophis during the few days of the flyby), the asteroid moves in Earth's gravity alone. The 3D scene integrates r'' = -mu r / |r|^3 with mu = 398,600 km^3/s^2 using fourth-order Runge-Kutta and an adaptive step (about 10 s near closest approach, 2 minutes far away), starting 900,000 km out on an exact hyperbola.
v_inf = 5.84 km/s (relative speed far from Earth)
e = 1 + q v_inf^2 / mu
b = (mu / v_inf^2) sqrt(e^2 - 1) (impact parameter)
v_peri = sqrt(v_inf^2 + 2 mu / q) (vis-viva)
turn = 2 asin(1/e) (deflection angle)
Orbit change. Far from Earth the speed is unchanged, but its direction is rotated by the turn angle. Seen from the Sun, Apophis' velocity is Earth's velocity plus v_inf, so rotating v_inf changes the heliocentric speed v. The new semi-major axis follows from the Sun-frame vis-viva equation 1/a = 2/r - v^2/(GM_sun), evaluated at Earth's distance r = 1 AU. With the public figures the model gives a: 0.93 to 1.12 AU, period 0.89 to 1.18 years, so Apophis changes from an Aten-type to an Apollo-type orbit (published values are about 0.92 to 1.13 AU).
Tides and spin. Earth's tidal field at 6 Earth radii may shake loose surface material and change the asteroid's spin; this model does not simulate it (the shape is treated as a point). The 3D rock is a stylised, procedurally cratered shape, not a radar shape model.
Brightness. V = H + 5 log10(r_sun * Delta) - 2.5 log10[(1-G) Phi1(alpha) + G Phi2(alpha)] with H = 19.09, G = 0.24 (assumed), r_sun and Delta in AU, alpha the Sun-asteroid-observer phase angle. The model reaches about magnitude 3.8 for the nearest ground observers; published estimates are around 3 to 3.5, and the difference comes from the uncertain phase law and shape. The graph shows when the model brightness crosses magnitude 6, the naked-eye limit under dark skies.
Why no impact. Earth's gravity bends the approach so the effective capture radius is b_hit = R sqrt(1 + 2mu/(R v_inf^2)) = 13,770 km. The predicted miss parameter is about 48,000 km, 3.5 times larger. Current orbit solutions include radar and years of optical data, and the 2029 passage is known to within a few kilometres and NASA has stated that no Earth impact is possible for at least the next 100 years.
Simplifications (honest list). Earth is a point mass (no J2, no atmosphere, no tides); the Moon, the Sun's tide and the Yarkovsky force are ignored in the integration (they change the path by far less than the plotted differences); the Moon's phase is an approximate circular orbit placed about one day before new moon; the closest-approach time is rounded to 21:46 UTC; the sky geometry (perigee direction, orbit plane) is calibrated so that the public orbit numbers are reproduced and is illustrative; Earth rotation uses a mean sidereal time; observers are treated as points at sea level, topocentric parallax included.
Independent checks. The numerical path is compared with analytic hyperbola results: energy and angular momentum conservation, perigee distance, vis-viva speed, deflection angle and the heliocentric semi-major axis computed from the outgoing asymptote (see the live table).
All numbers marked approximate are rounded public figures from NASA/JPL and ESA material, not a mission ephemeris. Educational model; no one needs to worry, no impact is possible in 2029.