Skip to content
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

How to get the formula for mouse movement vectors ? #130

Open
EthanH3514 opened this issue Jan 15, 2024 · 1 comment
Open

How to get the formula for mouse movement vectors ? #130

EthanH3514 opened this issue Jan 15, 2024 · 1 comment

Comments

@EthanH3514
Copy link

I wrote a similar project. This question has been bothering me for a long time.

I can get the location of the enemy projection on the screen. But how to get real mouse movement vectors? In the game, the angle at which the field of view moves is proportional to how many pixels the mouse moves. But there is a tangential relationship between the enemy's projection position and the angle of movement. How to get the distance between the camera and the screen?

I found a similar snippet in your code, so thought you must have found a workaround.

move_rel_x = self.pidx(atan2(-move_rel_x, self.detect_length) * self.detect_length)
move_rel_y = self.pidy(atan2(-move_rel_y, self.detect_length) * self.detect_length)

In this code, it seems that you are thinking that the distance between the camera and the screen is 640. I would like to know why this is possible and what the formula means. There is a mathematical principle behind this, or is it obtained by knowing the tangent relationship and adjusting the parameter coefficient?

I would be very grateful if you could answer my questions!

@PlutoNameless
Copy link
Collaborator

In the FPS game, the position of the mouse is fixed in the center of the screen, and what you send is the relative movement of the center of the screen and the target in two-dimensional space each time.
The 640 is the window size in the yolo process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants