Skip to content

About

tiny rotating donut implementaion -> following of my math transformation self learn session

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

  • this project is created, since I relealised by reviewing matrix roation, that I saw the transformation matrix in the classic rotation cube video Video Link
  • However, Im going to use a row-major, right-handed coordinate system, since it was introduced by ScratchAPixel ScratchAPixel
  • Here are my notes from the theory:

Rotation of a matrix

  • lets say on the x axis, we have the Point $Point = (1, 0, 0)$, by rotating it of $\theta = 90°$ and getting $P_T = (0, 1, 0)$ → This rotation R_00 otates P to 90° counterclockwise (thats why we getting from the X to the Y axis and not the -Y axis)
  • The calculation is:

$$ P_T.x = P.x * R_00 + P.y * R_10 + P.z * R_20 $$ $$ P_T.y = P.x * R_01 + P.y * R_11 + P.z * R_21 $$ $$ P_T.z = P.x * R_02 + P.y * R_12 + P.z * R_22 $$

  • Cosine and sine can be used to determine the coordinates of a point on both axises → for a point on the unit circle, its x and y coordinates with the cosine and sine of the angle $\theta$, respectively:

$$ x = cos(\theta) = 0 y = sin(\theta) = 1 given\theta = \frac{\pi}{2} -> same as 90° $$

  • The matrices for rotaion around the x and y axes can be derived similary with $R_x$ affecting rotation in the yz plane and $R_y$ in the xz plane. Those are the matrices for right handed and row-major matrices (completly different formula when using a different system). We are transforming a point via $\dot{v} = vR$ and not $\dot{v} = Rv$. There is no right and wrong here, but its the most used one:

$$ R_x(\theta) = \begin{bmatrix} 1 & 0 & 0 \cr 0 & cos(\theta) & sin(\theta) \cr 0 & -sin(\theta) & cos(\theta) \end{bmatrix} R_y(\theta) = \begin{bmatrix} cos(\theta) & 0 & -sin(\theta) \cr 0 & 1 & 0 \cr 0 & sin(\theta) & cos(\theta) \end{bmatrix} R_z(\theta) = \begin{bmatrix} cos(\theta) & sin(\theta)& 0\cr -sin(\theta) & cos(\theta) & 0 \cr 0 & 0 & 1 \end{bmatrix} $$

Screenshot

Screenshot from the terminal output

Resources

About

tiny rotating donut implementaion -> following of my math transformation self learn session

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages