reorganized. coded up geometry in c++