# Thread: How to transform multiple 3d points by different distances with a matix calculation?

1. ## How to transform multiple 3d points by different distances with a matix calculation?

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}$