1
$\begingroup$

If I have a 3d point $(x,y,z)$ and I want to translate it by a vector $v$, I can just multiply it by a matrix as shown here

https://en.wikipedia.org/wiki/Translation_(geometry)

Also I know that if I want to translate n points at the same time, I can just combine it into

$ \begin{bmatrix} 1 & 0 & 0 & v_x \\ 0 & 1 & 0 & v_y \\ 0 & 0 & 1 & v_z \\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x_1 & x_2 & \dots & x_n \\ y_1 & y_2 & \dots & y_n \\ z_1 & z_2 & \dots & z_n \\ 1 & 1 & \dots & 1 \end{bmatrix} = \begin{bmatrix} x_1' & x_2' & \dots & x_n' \\ y_1' & y_2' & \dots & y_n' \\ z_1' & z_2' & \dots & z_n' \\ 1 & 1 & \dots & 1 \end{bmatrix} $

But what if I want to translate n points, but each points moves by a different distance/vector. Is there a way to combine all the calculations in the least amount of matrix calculations so that I can feed it into the GPU to compute faster?

Does anyone know?

Thanks

EDIT

I can see 1 way, but does anyone know if there is a better way. This one seems to increase size of the matrix linearly by a factor of 4 for each point. $ \begin{bmatrix} 1 & 0 & 0 & v_{x1} & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & v_{y1} & 0 & 0 & 0 & 0 \\ 0 & 0 & 1 & v_{z1} & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 0 & 0 & v_{x2} \\ 0 & 0 & 0 & 0 & 0 & 1 & 0 & v_{y2} \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & v_{z2} \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x_1 & 0 \\ y_1 & 0 \\ z_1 & 0 \\ 1 & 0 \\ 0 & x_2 \\ 0 & y_2 \\ 0 & z_2 \\ 0 & 1 \\ \end{bmatrix} = \begin{bmatrix} x_1' & 0 \\ y_1' & 0 \\ z_1' & 0 \\ 1 & 0 \\ 0 & x_2' \\ 0 & y_2' \\ 0 & z_2' \\ 0 & 1 \\ \end{bmatrix} $

  • 0
    If you only encounter translations, then why would you use matrices for the translation? Essentially, what happens is $x_{i+1}=x_i+v_i$, which to me, seems quicker.2017-02-21
  • 0
    yes, but that's if there is only small amount of points, but I have hundreds of thousands, which I want to give to the gpu to crunch which is faster if u let it work on more data at the same time.2017-02-21
  • 0
    I see, interesting problem!2017-02-21
  • 0
    I added a possible way, but there might be better ways.2017-02-21

1 Answers 1

1

Your question is actually about computation, not mathematics. You want to exercise some GPU. If you have parallel processing, and want to translate a large number $n$ of points ${\bf x}_i$ by vectors ${\bf v}_i$, group them into a very long vector ${\bf X} = \{ {\bf x}_1, {\bf x}_2, \ldots {\bf x}_n \}$ and simply add ${\bf V} = \{ {\bf v}_1, {\bf v}_2, \ldots {\bf v}_n \}$.

  • 0
    oh yeah, I completely forgot about that approach, I was overthinking with matrices only, that's some next level thinking. Thanks. And I can still feed this into a GPU.2017-02-21