Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rotation angle calculation from affine transform array as matrix utils. #2

Open
softmarshmallow opened this issue Oct 6, 2021 · 0 comments

Comments

@softmarshmallow
Copy link
Member

The 2d space rotation angle extraction function is below. Add this to matrix utils.

function angleFromTransform(transform: Readonly<Transform>): number {
  try {
    const [a, b, c] = transform[0];
    const [d, e, f] = transform[1];
    var angle = Math.round(Math.atan2(b, a) * (180 / Math.PI));
    return angle < 0 ? angle + 360 : angle;
  } catch (e) {
    console.error(e);
    return 0;
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant