antoniogamiz / beta-tfg

Métodos de Monte-Carlo y desarrollo de software de síntesis de imágenes.
GNU General Public License v3.0
0 stars 0 forks source link

Simplify rotate and rect classes into one in each case #2

Open antoniogamiz opened 4 years ago

antoniogamiz commented 4 years ago

rotate_x, rotate_y and rotate_z, can be simplified as rotate(vec3 & axis, const double theta) where axis is one of {1,0,0}, {0,1,0} or {0,0,1}.

antoniogamiz commented 4 years ago

https://github.com/antoniogamiz/tfg/blob/acede765f17a6d3a3fe5a73add6f2ba2aaba0a59/src/include/hittable.h#L118-L119

https://github.com/antoniogamiz/tfg/blob/acede765f17a6d3a3fe5a73add6f2ba2aaba0a59/src/include/hittable.h#L141-L145

https://github.com/antoniogamiz/tfg/blob/acede765f17a6d3a3fe5a73add6f2ba2aaba0a59/src/include/hittable.h#L155-L159

All those functions could be simplified by:

void rotate(vec3& axis, point3& p, const double cos, const double sin)
antoniogamiz commented 4 years ago

axis should be declared as an enum or similar:

enum Axis { x = {1,0,0}, y = {0,1,0}, z = {0,0,1}};

or maybe macros

#define XAXIS {1,0,0}
...