Skip to content

Instantly share code, notes, and snippets.

@Craigtut
Created December 6, 2018 00:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Craigtut/6632a9ac7cfff55e74fb561862bc4edb to your computer and use it in GitHub Desktop.
Save Craigtut/6632a9ac7cfff55e74fb561862bc4edb to your computer and use it in GitHub Desktop.
Clockwise rotation with translation.
// event from touch event on a view
const { pageX, pageY } = event.nativeEvent;
const x0 = pageX / Metrics.screenWidth;
const y0 = pageY / Metrics.screenHeight;
const x = y0;
const y = -x0 + 1;
// x and y have now been rotated 90 deg clockwise and translated back into normalized coordinates.
@havanthanhit
Copy link

what's the Metrics?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment