updated algorithm: calculating Z-coordinate for RealWorld representation