Diamond Angle
This will calculate the clockwise or anti-clockwise angle (depending on coordinate system chirality) of a vector in a range of to where each whole unit is equal to .
One notable aspect of this method though is that it only calculates the positive angle, whereas a true trigonometric method would calculate the absolute minimum, giving negative angles instead of angles greater than . This can actually be quite useful in some situations but it is important to remember this distinction.
The formula to find the diamond angle, sometimes called the taxi-cab angle, of a vector in hectogradians (1 hgrad = 100 grad) is as follows:
Code
Example Python code
def diamond_angle(x, y):
if y >= 0 and x >= 0:
return y/(x+y)
elif y >= 0 and x < 0:
return 1-x/(-x+y)
elif y < 0 and x < 0:
return 2-y/(-x-y)
elif y < 0 and x >= 0:
return 3+x/(x-y)