c++ code for morphing