Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice


Discussion in 'Documentation' started by Baste, Dec 1, 2017.

  1. Baste


    Jan 24, 2013
    The documentation on this function is... confusing.

    There's two problems:
    1) "The angle returned is the signed acute clockwise angle between the two vectors. This means the smaller of the two possible angles between the two vectors is used. The result is never greater than 180 degrees or smaller than -180 degrees.

    Last I checked, "acute" angle means "less than 90 degrees". It might be that I've missed something, but your definition seems mutually exclusive? Unless what you're trying to do is to make up the term "signed acute", and then define it in the second sentence. Which is a mess.

    This would be a lot easier to read as a shorter explanation with examples:
    "The angle returned is the signed clockwise angle between the two vectors. The result is never greater than 180 degrees or smaller than -180 degrees.
    print(Vector2.SignedAngle(new Vector2(0, 1), new Vector2(0, 1)); //prints "90"
    print(Vector2.SignedAngle(new Vector2(1, 1), new Vector2(0, -1)); //prints "-135"

    2) Either the implementation is wrong, or the documentation is wrong. The documentation states that these are clockwise angles. But:
    Code (csharp):
    1. Vector2.SignedAngle(Vector2.up, Vector2.right); //gives -90
    2. Vector2.SignedAngle(Vector2.up, Vector2.left); //gives 90
    Which means that looking at the vectors from the standard 2D camera, the angles given are counterclockwise.
    I kinda get what's happening; Vector2.SignedAngle corresponds to Vector3.SignedAngle with the up-axis defined as Vector3.forward. Which is... a definition, sure. But that's not a clockwise angle! Unless I'm completely missing something, which might be the case.
    earhod and tigger like this.
  2. tigger


    Jan 8, 2013
    I'm somewhat new to Unity. Just noticed #2. Docs appear to be wrong.
  3. Erfan_Time


    Jun 22, 2018
    seems it is calculating from the second vector to the first vector that is the correct answer with clockwise angle
  4. Baste


    Jan 24, 2013
    @jo-unity, somebody just posted about this. Any chance to get a confirmation from someone on what's supposed to be happening here? The documentation isn't very rigid, and by the intuitive definition, the implementation and documentation doesn't match.

    In laymans terms, the current implementation gives that the angle from 12 o' clock to 3 o' clock is -90, if the clock is a normal 2D sprite facing the camera.