More a maths question then a programming one, but I need to code camera rotation and I have no idea how. The maths are a bit to abstract for me to do out of the blue.
The camera’s rotation is done with quaternions, all I really want is a sample to study or just an article about the subject but I can’t find anything.
More a maths question then a programming one, but I need to code camera
Share
here is something i wrote in opengl. the basic algorithm should be the same in any language. the things you need are:
the up vector of unit length (where up is defined if you are looking at the center): (upx, upy, upz)
origin (the place you are looking at): (ox,oy,oz)
camera position (where your camera is): (cx, cy, cz)
assume “del” is the amount you want to move, and that
after that, you can calculate the “forward” vector. that is, the vector which is unit length and points from you to the center via:
you can then calculate the unit “left” vector, that is, the vector pointing to the left of unit length if you are looking at the center:
you can then write the following routines (each original ‘//’ justified left signifies a new routine)