Skip to content

Camera Rotation Math #14

@Joshuawd190

Description

@Joshuawd190

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

Metadata

Metadata

Assignees

Labels

suggestionExternal ideas/inspiration

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions