A mean value theorem for tangentially convex functions