A Monotonic spatial function

intervoxel

I need an integer function that receives three integer parameters x,y,z and returns a unique value. An additional constraint is that the nearest neighbors points return a value that doesn't exceed a small value. The maximum value for the inputs is N.

Thank you for any help.

Mark44

Mentor
How does monotonic figure in here? In different words you want a function f that maps $\mathbb R^3$ to $\mathbb R$, but using integer values for the inputs.
For a real-value function g of a real variable, g is monotonically increasing provided that $a < b \Rightarrow g(a) \le g(b)$.

For a function whose input is an ordered triple, (x, y, z) how do you determine that $(x_1, y_1, z_1) < (x_2, y_2, z_2)$ in order to show montonicity?

mfb

Mentor
What "doesn't exceed a small value" mean?

$(x,y,z) \to (N+1)^2 x + (N+1) y + z$ or something similar can work. If the return value doesn't have to be an integer you have more freedom.

intervoxel

What "doesn't exceed a small value" mean?

$(x,y,z) \to (N+1)^2 x + (N+1) y + z$ or something similar can work. If the return value doesn't have to be an integer you have more freedom.
Thank you for the answers so far. The above function is indeed monotonic but does not return a unique value for each triplet. I tried
if(y <= z)
r = 3*N*N*x + y+N*z+1;
else
r = 3*N*N*x + 3*N*y-z;
but it generates some duplicates.

mfb

Mentor
The above function is indeed monotonic but does not return a unique value for each triplet
It does if x,y,z are integers from 0 to N inclusively (or 1 to N, doesn't matter here).

It is a simple numbering, row by row, column by column, layer by layer in 3D space.

• intervoxel

intervoxel

Thank you for the answers so far. The above function is indeed monotonic but does not return a unique value for each triplet. I tried
if(y <= z)
r = 3*N*N*x + y+N*z+1;
else
r = 3*N*N*x + 3*N*y-z;
but it generates some duplicates.
You're right. It works. I had tried with
It does if x,y,z are integers from 0 to N inclusively (or 1 to N, doesn't matter here).

It is a simple numbering, row by row, column by column, layer by layer in 3D space.
You're right. It works! I had tried with N instead of N+1 and that failed. Thank you.

"Monotonic spatial function"

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving