[raymath] Hotfix for Vector2Angle() and Vector2LineAngle() (#3396)
* Hotfix for Vector2LineAngle(), should probably be reviewed along with the rest of raylib angle functions to determine what coordinate system we want. * Hotfix for Vector2LineAngle(), should probably be reviewed along with the rest of raylib angle functions to determine what coordinate system we want. * [raymath] Hotfix for Vector2Angle and corresponding example * [raymath] Hotfix for Vector2Angle and corresponding example --------- Co-authored-by: Ray <raysan5@gmail.com>
This commit is contained in:
parent
f0d949f931
commit
9702a17152
2 changed files with 6 additions and 7 deletions
|
@ -44,7 +44,7 @@ int main(void)
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
float startangle;
|
float startangle;
|
||||||
|
|
||||||
if (angleMode == 0) startangle = -Vector2LineAngle(v0, v1)*RAD2DEG;
|
if (angleMode == 0) startangle = Vector2LineAngle(v0, v1)*RAD2DEG;
|
||||||
if (angleMode == 1) startangle = 0.0f;
|
if (angleMode == 1) startangle = 0.0f;
|
||||||
|
|
||||||
v2 = GetMousePosition();
|
v2 = GetMousePosition();
|
||||||
|
@ -82,7 +82,7 @@ int main(void)
|
||||||
DrawLineEx(v0, v1, 2.0f, BLACK);
|
DrawLineEx(v0, v1, 2.0f, BLACK);
|
||||||
DrawLineEx(v0, v2, 2.0f, RED);
|
DrawLineEx(v0, v2, 2.0f, RED);
|
||||||
|
|
||||||
DrawCircleSector(v0, 40.0f, startangle, startangle - angle, 32, Fade(GREEN, 0.6f));
|
DrawCircleSector(v0, 40.0f, startangle, startangle + angle, 32, Fade(GREEN, 0.6f));
|
||||||
}
|
}
|
||||||
else if (angleMode == 1)
|
else if (angleMode == 1)
|
||||||
{
|
{
|
||||||
|
@ -91,7 +91,7 @@ int main(void)
|
||||||
DrawLine(0, screenHeight/2, screenWidth, screenHeight/2, LIGHTGRAY);
|
DrawLine(0, screenHeight/2, screenWidth, screenHeight/2, LIGHTGRAY);
|
||||||
DrawLineEx(v0, v2, 2.0f, RED);
|
DrawLineEx(v0, v2, 2.0f, RED);
|
||||||
|
|
||||||
DrawCircleSector(v0, 40.0f, startangle, startangle - angle, 32, Fade(GREEN, 0.6f));
|
DrawCircleSector(v0, 40.0f, startangle, startangle + angle, 32, Fade(GREEN, 0.6f));
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawText("v0", v0.x, v0.y, 10, DARKGRAY);
|
DrawText("v0", v0.x, v0.y, 10, DARKGRAY);
|
||||||
|
|
|
@ -324,8 +324,7 @@ RMAPI float Vector2Angle(Vector2 v1, Vector2 v2)
|
||||||
float dot = v1.x*v2.x + v1.y*v2.y;
|
float dot = v1.x*v2.x + v1.y*v2.y;
|
||||||
float det = v1.x*v2.y - v1.y*v2.x;
|
float det = v1.x*v2.y - v1.y*v2.x;
|
||||||
|
|
||||||
// TODO(10/9/2023): Currently angles move clockwise, determine if this is wanted behavior
|
result = atan2f(det, dot);
|
||||||
result = -atan2f(det, dot);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue