Created
May 2, 2014 19:20
-
-
Save mcy/5b27c89aea90e3dfe24c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
* v - Vector to rotate | |
* e - unit Vector about which to rotate | |
* th - angle in radians | |
*/ | |
private static Vector rotate(Vector v, Vector e, double th){ | |
double cos = Math.cos(th); | |
double sin = Math.sin(th); | |
return (v.clone().multiply(cos)).add(e.clone().crossProduct(v).multiply(sin)).add(e.clone().multiply(e.dot(v)).multiply(1 - cos)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment