add compute3dPosition function