Skip to content

Instantly share code, notes, and snippets.

View Craigtut's full-sized avatar

Craig Tuttle Craigtut

View GitHub Profile
@Craigtut
Craigtut / portraitRotation.js
Created December 6, 2018 00:42
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.