The armillary sphere, a three-dimensional representation of the movements in the celestial sphere, was invented in Han China by the 1st century BC. Using a water clock, waterwheel and a series of gears, the Court Astronomer Zhang Heng (78–139 AD) was able to mechanically rotate his metal-ringed armillary sphere. To address the problem of slowed timekeeping in the pressure head of the inflow water clock, Zhang was the first in China to install an additional tank between the reservoir and inflow vessel. Zhang also invented a seismometer (Houfeng didong yi 候风地动仪) in 132 AD to detect the exact cardinal or ordinal direction of earthquakes from hundreds of kilometers away. This employed an inverted pendulum that, when disturbed by ground tremors, would trigger a set of gears that dropped a metal ball from one of eight dragon mouths (representing all eight directions) into a metal toad's mouth.