# I would like to generate a $\mathbb{Z}^5$ lattice with geometry nodes

The image shows a way to generate $$\mathbb{Z}^3$$ lattice and a $$\mathbb{Z}^2$$ lattice.

The coordinates from the cube vertices are

(-2,-2,-2)

(-1,-2,-2)

...

( 2, 2, 2)

and from the plane vertices

(-2,-2,0)

(-1,-2,0)

...

( 2, 2, 0)

However, I need a $$\mathbb{Z}^5$$ lattice. Is there a possibility to combine every vertex of the plane with every vertex of the cube to obtain something like this:

(-2,-2,-2) (-2,-2,0)

(-1,-2,-2) (-2,-2,0)

...

( 2, 2, 2) (2, 2, 0)

In mathematics this operation is called direct product, but I have no glue how to set this up in geometry nodes. All the following operations would act on the set of all possible five tuples. I hope that this is not too technical.

• How would you like to output the result ? Right now, I am thinking of instancing the plane at each vertex of the cube. Choosing a vertex of the cube will give you the first part (i,j,k). Then choosing a vertex of the plane will give you the second part (l,m). But I am in the dark about how you could use this... Mar 24 at 17:00
• Another approach is to create a 5^5=3125 point cloud, then to decode the index n as n=(i+2)+5*{(j+2)+5*[(k+2)+5*{(l+2)+5*(m+2)}]} (more or less...) Mar 24 at 17:06
• I'm not in the mood to look up any formulas, but I guess there surely are formulas to calculate this "by hand". So it should be possible to setup Vector Math and Math nodes probably with the help of Separate XYZ and Combine XYZ nodes to recreate this step by step. I mean, people are also recreating fractals and Aizawa strange attractors with Math nodes so I guess it is just a matter of knowing the formulas. Mar 24 at 17:13
• I think the point cloud will do the job. This is great! Mar 24 at 17:35
• If the point-cloud does it.. I'd be intrigued to see the mechanics. I hope one of you writes it up as an answer. Mar 24 at 17:49

(Using Blender 3.6.8)

Let $$K \in \mathbb{N}$$ such that $$i, j, k, l, m \in [-K,K] \cap \mathbb{Z}$$.
Let $$B$$ such that $$B=2K+1$$.

The tuple $$(i,j,k,l,m)$$ is encoded in the index $$n$$ as: $$\begin{array}{rcl} n & = & 1 \times (i+K) \\ & + & B \times (j+K) \\ & + & B^2 \times (k+K) \\ & + & B^3 \times (l+K) \\ & + & B^4 \times (m+K) \end{array}$$

To decode $$n$$, a recursive process is used. Let $$I^t-K$$ stands for $$i,j,k,l,m$$ with $$t=0,1,2,3,4$$ respectively. Let $$N^t$$ such that $$N^t=I^t+B \times N^{t+1}$$, with $$N^0=n$$. Then:

$$I^t = N^t \ \mathrm{mod} \ B$$ $$N^{t+1} = \frac{N^t - I^t}{B}$$

1. $$K$$ is set to $$2$$.
2. A Point Cloud of $$B^5$$ points is initialized.
3. $$(i,j,k)$$ are stored in a first vector.
4. $$(l,m)$$ are stored in a second vector.

1. NodeGroup computing $$I^t$$ and updating $$N^t$$.

Resources:

The hint from

@StefLAncien

with the point cloud helped to solve the problem. The following solution generates $$\mathbb{Z}^5$$ vectors. The range $$r$$ determines the maximal absolute value for components of the the vector. It must be smaller than 9. So at most vectors from (-9,-9,-9,-9,-9) to (9,9,9,9,9) can be created.

To achieve this a point cloud of the size $$b^5$$ with $$b=(2r+1)$$ is created. The index $$i$$ is mapped into the vector $$(d_1,d_2,d_3,d_4,d_5)$$ according to the following rule: $$i = (d_1-r) \cdot b^4+(d_2-r)\cdot b^4+(d_3-r)\cdot b^2+(d_4-r)\cdot b+(d_5-r)$$

This map is performed in the node "Index2Tuple" which is displayed in a separate image. To make the result visible the 5-tuples are split into a 3-dimensional vector and a 2-dimensional one. This yields two sets of points shown in the images for $$r-3$$ and $$r-5$$.

Resource: