Just as the title says. I tried adding the angles and dividing by two, but that didn’t give proper results. I tried converting the angles to two-component vectors then finding the mid-point between them(by normalizing their sum), but that approach fails when the two angles are exactly opposite. Any suggestions? Thanks.
In case it’s not clear what I mean by mid-point: I mean the angle that is exactly halfway between one angle and another(and I’m talking 2D angles, not Euler angles).
Here’s an example to show the problem: 355 degrees and 5 degrees are only 10 degrees apart from each other. The real mid-point between them would be 360 or 0 degrees. However, (355 + 5) /2 = 180, which is clearly an incorrect answer.
Blender actually uses radians instead of degrees, but the problem is the same either way.
I think I may have figured it out now. It involves conversion to vectors and atan2. Here’s a sample, if anyone’s interested:
import math
pi = math.pi
Angle1 = (Insert any number)
Angle2 = (Insert any number)
Vec1 = (math.sin(Angle1), math.cos(Angle1))
Vec2 = (math.sin(Angle2), math.cos(Angle2))
VecSum = tuple(sum(x) for x in zip(Vec1, Vec2))
FinalVec = VecSum
FinalVec = tuple(x/(math.sqrt(VecSum[0]**2 + VecSum[1]**2)) for x in FinalVec)
FinalAngle = math.atan2(FinalVec[0], FinalVec[1])
FinalAngle is the midpoint of Angle1 and Angle2. I’m not 100% sure it works, but it seems to so far.