DaTaobao Tech
Aug 8, 2022 · Game Development
2D Vector Rotation: Theory and Implementation
Rotating a 2‑D vector is performed by multiplying it with the matrix [[cos θ, ‑sin θ],[sin θ, cos θ]], yielding the new coordinates (x cos θ ‑ y sin θ, x sin θ + y cos θ); a short JavaScript function implements this, turning [3,2] into [‑2,3] for a 90° counter‑clockwise rotation and also rotates the basis vectors.
2DGraphicsJavaScript
0 likes · 8 min read