  Let $P$ be a set of $n$ points in real projective $d$-space, not all
contained in a hyperplane, such that any $d$ points span a hyperplane. An
ordinary hyperplane of $P$ is a hyperplane containing exactly $d$ points of
$P$. We show that if $d\ge 4$, the number of ordinary hyperplanes of $P$ is at
least $\binom{n-1}{d-1} - O_d(n^{\lfloor(d-1)/2\rfloor})$ if $n$ is
sufficiently large depending on $d$. This bound is tight, and given $d$, we can
calculate the exact minimum number for sufficiently large $n$. This is a
consequence of a structure theorem for sets with few ordinary hyperplanes: For
any $d \ge 4$ and $K > 0$, if $n \ge C_d K^8$ for some constant $C_d > 0$
depending on $d$ and $P$ spans at most $K\binom{n-1}{d-1}$ ordinary
hyperplanes, then all but at most $O_d(K)$ points of $P$ lie on a hyperplane,
an elliptic normal curve, or a rational acnodal curve. We also find the maximum
number of $(d+1)$-point hyperplanes, solving a $d$-dimensional analogue of the
orchard problem. Our proofs rely on Green and Tao's results on ordinary lines,
our earlier work on the $3$-dimensional case, as well as results from classical
algebraic geometry.
