Points enclosed by a custom defined Hypercube

496 Views Asked by At

I have a N-dimensional vector, X and 'n' equidistant points along each dimension and a parameter 'delta'. I need a way to find the total of n^N vectors enclosed by the Hypercube defined with the vector X at the center and each side of Hypercube being of size 2*delta.

For example:

Consider a case of N=3, so we have a Cube of size (2*delta) enclosing the point X.

------------\
|\--------|--\
| |   X   |  |
-----------  |
\ |_2*del___\|

Along each dimension I have 'n' points. So, I have a total of n^3 vectors around X. I need to find all the vectors. Is there any standard algorithm/method for the same? If you have done anything similar, please suggest.

If the problem is not clear, let me know.

This is what I was looking at: Considering one dimension, length of a side is 2*delta and I have n divisions. So, each sub-division is of size (2*delta/n). So I just move to the origin that is (x-delta) (since x is the mid point of the side) and obtain the 'n' points by {(x-delta) + 1*(2*delta/n),(x-delta) + 2*(2*delta/n)....+ (x-delta) + 1*(n*delta/n) } . I do this for all the N-dimensions and then take a permutation of the co-ordinates. That way I have all the points.

(I would like to close this)

2

There are 2 best solutions below

3
On

Ok, I didn't fully understand your question. There are total of 2^(N-1)*N "lines" about a point in an N-dimensional hypercube.

If you just want to create n points on lines which look like the axis, but translated at a distance of delta from the origin, here's some (poorly written, for clarity) MATLAB code:

n = 10;
delta = 10;
N = 3;
step = (2*delta)/(n-1);
P = zeros(n,N,N);
X = [20 30 25];

for line_dim = 1:N
 for point = 1:n
  for point_dim = 1:N

   if(point_dim ~= line_dim) 
    P(point,point_dim,line_dim) = X(point_dim)-delta;
   else 
    P(point,point_dim,line_dim) = X(point_dim)-delta+step*(point-1);
   end

  end
 end
end

The code's for a cube, but it should work for any N. All I've done is:

  1. Draw those n equidistant points on the axes.
  2. Translate the axes by (X-delta)

Display:

% Display stuff    
PP = reshape(permute(P,[1 3 2]),[n*N N]);
plot3(X(1),X(2),X(3),'r*',PP(:,1),PP(:,2),PP(:,3),'.')
axis([0 Inf 0 Inf 0 Inf]);
grid on;
0
On

If i understand your problem correctly, you have an axis-aligned hypercube centred around a point X, and you have subdivided the interior of this hypercube into a regular lattice where the lattice points and spacing are in the coordinate system of the hypercube. All you have to do is let X = 0, find the vectors to each of the lattice points, and then go back and translate them by X.

Edit: let me add an example

let x = (5,5,5), delta = 1 and n = 3

then, moving x to the origin, your lattice points are (-1, -1, -1), (0, -1, -1), (1, -1, -1) and so on for a total of 27. translating back, we have (4, 4, 4), (5, 4, 4), (6, 4, 4) and so on.