ah, I found it -- what I really want to calculate is the eccentricity vector.
This lecture notes also helped. I just tried implementing it in Javascript and it worked correctly on the first try! :-)
Here's what worked for me:
$$ \begin{eqnarray} \vec{h} &=& \vec{r} \times \vec{v} \\ \mu\vec{e} &=& \vec{v} \times \vec{h} - \frac{\mu}{r}\vec{r} \\ \vec{r}_{orbit}(\theta) &=& \frac{|h|^2 \hat{u}(\theta)}{\mu + \mu\vec{e}\cdot\hat{u}(\theta) } \end{eqnarray}$$
where $\vec{h}$ is the angular momentum, $\mu \vec{e}$ is the Laplace vector ($\mu = MG$, and $\vec{e}$ is the eccentricity vector), and $\hat{u}(\theta) = \hat{u}_x \cos \theta + \hat{u}_y \sin \theta$ is the unit vector in the orbital plane, as a function of $\theta$, which represents the angle in polar coordinates used to draw the orbit.