Created
August 4, 2014 09:22
-
-
Save mooman219/e7a61c3564648e05aa0a 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
public static List<Vector> rotateX(List<Vector> vectors, double degrees) { | |
List<Vector> result = new ArrayList<>(vectors.size()); | |
double cos = Math.cos(Math.toRadians(degrees)); | |
double sin = Math.sin(Math.toRadians(degrees)); | |
for (Vector target : vectors) { | |
result.add(new Vector( | |
target.getX(), | |
cos * target.getY() - sin * target.getZ(), | |
sin * target.getY() + cos * target.getZ())); | |
} | |
return result; | |
} | |
public static List<Vector> rotateY(List<Vector> vectors, double degrees) { | |
List<Vector> result = new ArrayList<>(vectors.size()); | |
double cos = Math.cos(Math.toRadians(degrees)); | |
double sin = Math.sin(Math.toRadians(degrees)); | |
for (Vector target : vectors) { | |
result.add(new Vector( | |
cos * target.getX() - sin * target.getZ(), | |
target.getY(), | |
sin * target.getX() + cos * target.getZ())); | |
} | |
return result; | |
} | |
public static List<Vector> rotateZ(List<Vector> vectors, double degrees) { | |
List<Vector> result = new ArrayList<>(vectors.size()); | |
double cos = Math.cos(Math.toRadians(degrees)); | |
double sin = Math.sin(Math.toRadians(degrees)); | |
for (Vector target : vectors) { | |
result.add(new Vector( | |
cos * target.getX() - sin * target.getY(), | |
sin * target.getX() + cos * target.getY(), | |
target.getZ())); | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment