added 3d coords and canonicalize functions