由自定义超立方体包围的点

发布于 2024-08-07 16:29:03 字数 644 浏览 12 评论 0原文

我有一个 N 维向量、沿每个维度的 X 和“n”等距点以及参数“delta”。我需要一种方法来找到超立方体包含的 n^N 个向量的总数,该超立方体以向量 X 为中心,超立方体每边的大小为 2*delta。

例如:

考虑 N=3 的情况,因此我们有一个大小为 (2*delta) 的立方体,包围点 X。

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

沿着每个维度,我有“n”个点。所以,我在 X 周围总共有 n^3 个向量。我需要找到所有向量。有没有相同的标准算法/方法?如果您做过类似的事情,请推荐。

如果问题不清楚,请告诉我。

这就是我所看到的:考虑一维,边长是 2*delta 并且我有 n 个分区。因此,每个细分的大小为 (2*delta/n)。所以我只是移动到原点 (x-delta)(因为 x 是边的中点)并通过 {(x-delta) + 1*(2*delta/n) 获得“n”个点, (x-delta) + 2*(2*delta/n)....+ (x-delta) + 1*(n*delta/n) } 。我对所有 N 维执行此操作,然后对坐标进行排列。这样我就拥有了所有的点。

(我想关闭此)

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)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

甜嗑 2024-08-14 16:29:03

如果我正确理解你的问题,你有一个以 X 点为中心的轴对齐超立方体,并且你已将该超立方体的内部细分为规则晶格,其中晶格点和间距位于超立方体的坐标系中。您所要做的就是让 X = 0,找到每个格点的向量,然后返回并通过 X 平移它们。

编辑:让我添加一个示例

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

然后,将 x 移动到原点,您的格点为 (-1, -1, -1), (0, -1, -1), (1, -1, -1) 等等总共 27 个。翻译回来,我们有 (4, 4, 4), (5, 4, 4), (6, 4, 4) 等等。

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.

你是暖光i 2024-08-14 16:29:03

好吧,我没有完全理解你的问题。 N 维超立方体中的一个点总共有 2^(N-1)*N 条“线”。

如果您只想在看起来像轴的线上创建 n 个点,但平移距离原点 delta 距离,这里有一些(为了清晰起见,写得不好)MATLAB 代码:

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

该代码适用于立方体,但它应该适用于我所做的就是:

  1. 在轴上画出这 n 个等距点。
  2. 将轴平移 (X-delta)

显示:

% 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;

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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文