extended to 3-D, can extend to any dimension with minor changes