Basically, these types of equation are just a clever way of combining
several 'current heading'-sensitive routines. Imagine that you wanted to
find the coordinates of the square behind an enemy which is directly in
front of you. The calculation differs depending on which way you are facing.
Here's how the four different equations can be built up into one big
equation which does the same thing:
The division at the end of each line is just a scaling factor. For example, when the cybug is facing north, the first three brackets of the north-facing part of the equation will be (1-2)*(1-3)*(1-4) which equals -6. This is multiplied with the stuff that we want to calculate, so we need to then divide by -6 to end up with the correct values.
So how do you figure out what Torque is calculating in these huge equations? Well, I've tried to simplify things a bit by color-coding the equations. The important bits are colored violet, and then other stuff is white (as in the example here). Also, they are always in the same order, so the first violet part is what is calculated if Torque is facing north. The second part is calculated when Torque is facing east. The third part is for south and the last violet-colored part is for west.
It all seems a little complicated, but if you use the equation and just change the violet parts to suit your cybug, then it should all work well.