Update ch3d.c

Everything but the planar case has been written.
Still untested.