I tried to get the angle between two Vector3’s using Vector3.Angle and got a return value I didn’t expect.

The two vectors where (1, 0, 0) and (0.00001, 0, 0) and the angle between the two should obviously be 0. However, Vector3.Angle returns 90.

This isn’t related to the length difference of the vectors, Vector3.Angle also reports the angle between (0.00001, 0, 0) and itself as 90. On the other hand, the difference between (1000000, 0, 0) and itself or (1, 0, 0) is reported correctly as 0.

Is this related to the algorithm used by Vector3.Angle or a bug? The documentation doesn’t say anything about it expecting only vectors in a specific range or only normalized ones.

Normalizing probably is the issue here. The documentation on Vector3.Normalize states:

If the vector is too small to be normalized a zero vector will be returned.

Vector3.Angle probably normalizes the input vectors, calculating the angle between (1, 0, 0) and (0, 0, 0). Vector3.Angle also seems to return 90 when either of its input vectors has zero length.