why waste your time on this, you can simply make GDK handle all the math for you
void OrbitCamera ( int pivotX, int pivotY, int pivotZ, float fYaw, float fPitch, float fDistance )
{
dbSetCameraPosition ( pivotX, pivotY, pivotZ );
dbSetCameraAngle ( 0, 0, 0 );
dbTurnCameraRight ( fYaw );
dbPitchCameraDown ( fPitch );
dbMoveCamera ( -fDistance );
}
simply call this function every loop, parameters are: pivot x/y/z are the pivot (the center), fYaw is the angle to turn (angle Y), fPitch is the angle to pitch (up - down), fDistance is the distance from the pivot
very simple and works fine
hope this helps, sorry if you know this but want to use some math