Original Post
I managed to get this function working with a left handed coordinate system, but I am having trouble converting to the default OpenGL system. This function is meant to increment the passed variables based on the passed rotation angles and length offset.
'lengthdir(x,y,z, 10, 0,90,90);'
Assuming an original position of (0,0,0), the new position should be (0,10,0) after the above call.
There are a few unnecessary/redundant bits, but I like to keep everything obvious until I have it working properly.
As it stands, all 'ydir' values work as expected while 'zdir' is equal to zero, but any change causes problems. I have not tested 'xdir' yet, and inversing the y output did not work.
Any help or advice on this issue would be greatly appreciated.
'lengthdir(x,y,z, 10, 0,90,90);'
Assuming an original position of (0,0,0), the new position should be (0,10,0) after the above call.
void lengthdir(float &x,float &y,float &z, float length,float xdir,float ydir,float zdir)//3 angles{ float sinx=sin(d2r*xdir), cosx=cos(d2r*xdir); float siny=sin(d2r*ydir), cosy=cos(d2r*ydir); float sinz=sin(d2r*zdir), cosz=cos(d2r*zdir); float X,Y,Z; //Xoffset X=Y=Z=0; Y=-length*sinx; Z=length*cosx; X=Z*siny; x+=X*cosz-Y*sinz; //Yoffset X=Y=Z=0; Y=-length*sinx; Z=length*cosx; X=Z*siny; y+=Y*cosz+(X*sinz); //Zoffset X=Y=Z=0; z+=length*cosx*cosy;}There are a few unnecessary/redundant bits, but I like to keep everything obvious until I have it working properly.
As it stands, all 'ydir' values work as expected while 'zdir' is equal to zero, but any change causes problems. I have not tested 'xdir' yet, and inversing the y output did not work.
Any help or advice on this issue would be greatly appreciated.