@Test public void testComputeWindowMatrix() { int x = 0; int y = 0; int width = 100; int height = 200; Viewport viewport = createViewport(x, y, width, height); Matrix33 windowMatrix = viewport.computeWindowMatrix(); Vector2 v0 = new Vector2(-1, -1); Vector2 v1 = new Vector2(1, 1); v0 = windowMatrix.transform(v0); v1 = windowMatrix.transform(v1); assertEquals(x, v0.getX(), delta); assertEquals(y, v0.getY(), delta); assertEquals(width, v1.getX(), delta); assertEquals(height, v1.getY(), delta); }
public Matrix33 computeWindowMatrix() { return Matrix33.makeTranslate(x, y) .multiply(Matrix33.makeScale(0.5 * (double)width, 0.5 * (double)height)) .multiply(Matrix33.makeTranslate(1.0, 1.0)); }
Viewport { public Matrix33 computeWindowMatrix() { return Matrix33.makeTranslate(x, y) .multiply(Matrix33.makeScale(0.5 * (double)width, 0.5 * (double)height)) .multiply(Matrix33.makeTranslate(1.0, 1.0)); } }
Viewport { public Matrix33 computeWindowMatrix() { return Matrix33.makeTranslate(x, y) .multiply(Matrix33.makeScale(0.5 * (double)width, 0.5 * (double)height)) .multiply(Matrix33.makeTranslate(1.0, 1.0)); } Viewport(); }
Viewport { public Matrix33 computeWindowMatrix() { return Matrix33.makeTranslate(x, y) .multiply(Matrix33.makeScale(0.5 * (double)width, 0.5 * (double)height)) .multiply(Matrix33.makeTranslate(1.0, 1.0)); } Viewport(); Matrix33 computeWindowMatrix(); int getX(); void setX(int x); int getY(); void setY(int y); int getWidth(); void setWidth(int width); int getHeight(); void setHeight(int height); }
Viewport { public Matrix33 computeWindowMatrix() { return Matrix33.makeTranslate(x, y) .multiply(Matrix33.makeScale(0.5 * (double)width, 0.5 * (double)height)) .multiply(Matrix33.makeTranslate(1.0, 1.0)); } Viewport(); Matrix33 computeWindowMatrix(); int getX(); void setX(int x); int getY(); void setY(int y); int getWidth(); void setWidth(int width); int getHeight(); void setHeight(int height);  }