Function toHomogeneous

toHomogeneous(p) takes a vector $p$ of length $n$, encoding a point in $n$-dimensional Cartesian coordinates, and returns a vector $q$ of length $n+1$, encoding the same point in homogeneous coordinates.