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

Camera Rotation Math #14

Open
Joshuawd190 opened this issue Dec 15, 2022 · 0 comments
Open

Camera Rotation Math #14

Joshuawd190 opened this issue Dec 15, 2022 · 0 comments
Assignees
Labels
suggestion External ideas/inspiration

Comments

@Joshuawd190
Copy link

Hiya, Sajji here

Some theoretical camera rotation implementation I haven't tested yet:

x = cos(angle) * x + -sin(angle) * y
y = sin(angle) * x + cos(angle) * y
note: angle is in radians, may want to use a math function version that uses degrees

This math should rotate a point around the focal point of the camera/viewplane.

Math Ref

I believe it would do so around the horizon, but I'm not sure.

The psuedo implementation I wrote up:

  • Intercept the projected road points before the polygon is rendered to the projection
  • Convert projected road points to coord pairs via a non mutating method
  • Apply the rotation math to the (x, y) pairs
  • Return the new points as an array
  • spread the array to the draw function

If that works how I think, it should rotate the road by whatever amount you want.
To finish the implementation, you'd also have to rotate the coords and angle of the sprites and adjust the rotation of the background elements.

Anyway, that's the current results of my Camera math research

@Coestar Coestar self-assigned this Dec 15, 2022
@Coestar Coestar added the suggestion External ideas/inspiration label Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion External ideas/inspiration
Projects
None yet
Development

No branches or pull requests

2 participants