@Test public void testCoordinatesAfterRotation() { Vector2 point = new Vector2(2d, 0d); Double rotation = 50 * Math.PI / 180; DecimalFormat df = new DecimalFormat("0.00", new DecimalFormatSymbols(Locale.ENGLISH)); assertThat(df.format(Geometry.coordinatesAfterRotation(point, rotation).x)).isEqualTo("1.29"); assertThat(df.format(Geometry.coordinatesAfterRotation(point, rotation).y)).isEqualTo("1.53"); }
public static Vector2 coordinatesAfterRotation(Vector2 coordinates, Double rotation) { return new Vector2( coordinates.x * Math.cos(rotation) - coordinates.y * Math.sin(rotation), coordinates.x * Math.sin(rotation) - coordinates.y * Math.cos(rotation)); }
Geometry { public static Vector2 coordinatesAfterRotation(Vector2 coordinates, Double rotation) { return new Vector2( coordinates.x * Math.cos(rotation) - coordinates.y * Math.sin(rotation), coordinates.x * Math.sin(rotation) - coordinates.y * Math.cos(rotation)); } }
Geometry { public static Vector2 coordinatesAfterRotation(Vector2 coordinates, Double rotation) { return new Vector2( coordinates.x * Math.cos(rotation) - coordinates.y * Math.sin(rotation), coordinates.x * Math.sin(rotation) - coordinates.y * Math.cos(rotation)); }  }
Geometry { public static Vector2 coordinatesAfterRotation(Vector2 coordinates, Double rotation) { return new Vector2( coordinates.x * Math.cos(rotation) - coordinates.y * Math.sin(rotation), coordinates.x * Math.sin(rotation) - coordinates.y * Math.cos(rotation)); }  static boolean isInsideTriangle(Vector2 p, Vector2 pA, Vector2 pB, Vector2 pC); static boolean isInsideTriangle(Vector2 p, Triangle triangle); static boolean areTrianglesColliding(Triangle triangle1, Triangle triangle2); static Vector2 coordinatesAfterRotation(Vector2 coordinates, Double rotation); }
Geometry { public static Vector2 coordinatesAfterRotation(Vector2 coordinates, Double rotation) { return new Vector2( coordinates.x * Math.cos(rotation) - coordinates.y * Math.sin(rotation), coordinates.x * Math.sin(rotation) - coordinates.y * Math.cos(rotation)); }  static boolean isInsideTriangle(Vector2 p, Vector2 pA, Vector2 pB, Vector2 pC); static boolean isInsideTriangle(Vector2 p, Triangle triangle); static boolean areTrianglesColliding(Triangle triangle1, Triangle triangle2); static Vector2 coordinatesAfterRotation(Vector2 coordinates, Double rotation);  }