|
For two conditions you can use the Excel IF function as follows:
Assume
Xa = A1 Xb = B1 'theta' = C1
then the Excel formula is:
=IF(B1 < A1,360 - C1,C1)
For more than two conditions you can nest IFs or use MATCH and CHOOSE together much like a select-case structure.
For processing angles in degrees I would suggest using a Modulus 360 function instead of "360-x", so that if you go over 360 or under 0 it "wraps around." So just let the IF decide the case and Mod360 the result as follows:
=MOD(IF(B1 < A1,-C1,C1),360)
As a side note, since a comparison test returns a boolean value, and false = 0, true = 1, you don't even need the IF. Just switch the order of the comparison, multiply the result by two and subtract 1. This will give you 1 or -1, which you then multiply by theta and modulus 360 the whole thing.
=MOD(((A1 < B1)*2 - 1) * C1, 360)
Hope this helps!
Edited by phageghost on 07/16/2007 13:02:26 MDT.
|