I encountered an error so wrong i thought i may need to rewrite my entire code
Whilst building the actual voxel renderer, it seems i may or may not have encountered a totally splendid error that changed my perspective on the whole rendering process, the Gimble lock.
I was using a Perspective camera in the 3js canvas, and very recently i tried to implement rotation (mouse rotation, i havent figured out animated gestures YET)
and it seemed at some point the camera only moved on 2 axis and refused to move on the other one, i just lost 1 degree of rotation? the fix is something completely out of pocket (istg this didnt make sense to me till like i pulled out my old project and tried sum shi) we use quaternions!? so basically real number is in the form
A(a)=a //real num
A(a,b)=a+bi //complex num
vvv
A(a,b,c,d)=a+bi+cj+dk //quaternions
as complex numbers we know, a and b are real numbers and i is the complex unit. (can represent 2d vectors)
In quaternions, were showing a 4d vector, end of story? no (sadly) then why not use trinions? or why even use polynions?
in complex plane we know the imaginary unit i is root(-1), vectorwise, we know a+ib, where a is the x unit and b is y unit basically (a,b) vector. where things like rotation by 90deg and stuff can be done easily as i^2=-1, so we can exchange between the initial x representator and y representator. there is no 3 way of 1,i,j that ever works this way so trinions arent a thing, …but quaternions CAN behave similarly
A(a,b,c,d)=a+bi+cj+dk…if we take a=0, A(b,c,d)=bi+cj+jk would u look at that? it suddenly represents a 3d vector. Although learning this was very informative, 3jd does have quaternions inbuilt so i didnt have to necessarily add anything extra, so all i had to do was implement quaternion based stepping rotation and voila! no gimble lock
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.