New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vector2.angleRad(Vector2) returns angle toward -y (instead of toward +y) #5385
Comments
It is actually correct, maybe the wording of the docs could be improved. Basically the key point here is that order matters. If you calculate the counter-clock angle between (0, 1) and (1, 0) you should get 270º which is what On the other hand |
Sorry I don't understand. How can
It seems we don't have the same definition of "reference". If I draw an arrow from one vector to the other in order to represent the angle. For me "reference" is the vector from which that arrow starts. In the following picture I consider the black vector to be the reference:
So the reference is the x-axis (not the instance from which the function is called)
Here the reference is explicitly the argument (not the instance from which the function is called) Vector2 vector = Vector2.Y;
Vector2 reference = Vector2.X;
System.out.println(vector.angleRad()); // I expect 1.5707964 (and I get it)
System.out.println(vector.angleRad(reference)); // I expect 1.5707964 (and I don't get it) |
By the way, as a side question, may I ask what is the rationale behind the fact that Why not return values between |
I do agree that the docs can be improved because "relative to" may be misleading. Using your definitions, To your second question I guess the main reason is just that Math.atan2 returns in the range |
No. The other way around. And the argument is not named "argument" it is named "reference"! But let's make it simpler: Documentation of
In the specific case of using the x-axis as a "given vector" like in
Here we see that this statement is identical to the documentation stated in
From that premise, it does not matter how one understand "relative to" and "reference". For all vector |
Agree, the javadoc comment was probably copied from one to another and should be inverted on |
Implementation has to be fixed. |
fixed by #5428 |
Issue details
Documentation of
Vector2.angleRad(Vector2)
states:So based on this statement
Vector2.Y.angleRad(Vector2.X)
should returnMath.PI / 2
.But it returns
-Math.PI / 2
Reproduction steps/code
Version of LibGDX and/or relevant dependencies
1.9.8
Please select the affected platforms
Should not be platform related. This is only math. But I observed the problem on Windows.
The text was updated successfully, but these errors were encountered: