Created
February 21, 2021 03:44
-
-
Save joehonton/46cdfccb5a577416ad07e25f8037e4e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// initial metrics | |
var initialRise = finger0.initial.y - finger1.initial.y; | |
var initialRun = finger0.initial.x - finger1.initial.x; | |
var initialTheta = Math.atan2(initialRise, initialRun); | |
var initialAngle = 180 - (initialTheta * 180 / Math.PI); | |
if (initialAngle < 0) | |
initialAngle += 180; | |
// latest metrics | |
var latestRise = finger0.latest.y - finger1.latest.y; | |
var latestRun = finger0.latest.x - finger1.latest.x; | |
var latestTheta = Math.atan2(latestRise, latestRun); | |
var latestAngle = 180 - (latestTheta * 180 / Math.PI); | |
if (latestAngle < 0) | |
latestAngle += 180; | |
// change in the angle between the two points over time | |
var deltaSweep = Math.abs(initialAngle - latestAngle); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment