I am trying to rotate a point in a 3D space in the 3 axis together around a specific origin point.
Unfortunately I can't use matrices in my application,All I can do is just the basic math operations (including the trigonometrical functions).
So Instead of the normal transformation matrix,I want a normal function that has 3 angles (x,y,z) and the original location of the vertex and the origin point location as inputs and return the new point location.
Is it possible to do that without using matrices?
The trick is to write out your matrices in homogeneous coordinates (with an extra column to allow for affine transformations i.e., translation matrices). Letting the point you want to rotate about equal $(a,b,c)$ gives:
$$ R_x(\theta) = \begin{bmatrix} 1 & 0 & 0 & 0\\ 0 & \cos\theta & -\sin\theta & 0 \\ 0 & \sin\theta & \cos\theta & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} $$
$$ R_y(\theta) = \begin{bmatrix} \cos\theta & 0 & \sin\theta & 0\\ 0 & 1 & 0 & 0 \\ -\sin\theta & 0 & \cos\theta & 0 \\ 0 & 0 & 0 & 1 \end{bmatrix} $$
$$ R_z(\theta) = \begin{bmatrix} \cos\theta & -\sin\theta & 0 & 0\\ \sin\theta & \cos\theta & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1 \end{bmatrix} $$
$$ T_1(a,b,c) = \begin{bmatrix} 1 & 0 & 0 & -a\\ 0 & 1 & 0 & -b\\ 0 & 0 & 1 & -c\\ 0 & 0 & 0 & 1 \end{bmatrix} $$
$$ T_2(a,b,c) = \begin{bmatrix} 1 & 0 & 0 & a\\ 0 & 1 & 0 & b\\ 0 & 0 & 1 & c\\ 0 & 0 & 0 & 1 \end{bmatrix} $$
Now applying these matrices as follows to a general vector $v = (x,y,z,1)^T$ gives a general formula:
$$ T_2(a,b,c)R_z(\theta)R_y(\theta)R_x(\theta)T_1(a,b,c)v. $$
Afterwards, the fourth entry of the vector can be dropped. The logic behind this is that you first translate $(a,b,c)$ to be at the origin, then you rotate, then you translate $(a,b,c)$ to be back to where it was originally.