From 7e59e4c57863cd972bd2df8205ef1153cbc53453 Mon Sep 17 00:00:00 2001 From: codeanticode Date: Thu, 10 Jan 2019 06:47:07 -0500 Subject: [PATCH] added 2D version of invMatrix utility methods --- .../processing/opengl/PGraphicsOpenGL.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/core/src/processing/opengl/PGraphicsOpenGL.java b/core/src/processing/opengl/PGraphicsOpenGL.java index 3caca761f..fd77bfd3a 100644 --- a/core/src/processing/opengl/PGraphicsOpenGL.java +++ b/core/src/processing/opengl/PGraphicsOpenGL.java @@ -3772,6 +3772,13 @@ public class PGraphicsOpenGL extends PGraphics { } + static protected void invTranslate(PMatrix2D matrix, + float tx, float ty) { + matrix.preApply(1, 0, -tx, + 0, 1, -ty); + } + + static protected float matrixScale(PMatrix matrix) { // Volumetric scaling factor that is associated to the given // transformation matrix, which is given by the absolute value of its @@ -3857,8 +3864,8 @@ public class PGraphicsOpenGL extends PGraphics { } - static private void invRotate(PMatrix3D matrix, float angle, - float v0, float v1, float v2) { + static protected void invRotate(PMatrix3D matrix, float angle, + float v0, float v1, float v2) { float c = PApplet.cos(-angle); float s = PApplet.sin(-angle); float t = 1.0f - c; @@ -3870,6 +3877,11 @@ public class PGraphicsOpenGL extends PGraphics { } + static protected void invRotate(PMatrix2D matrix, float angle) { + matrix.rotate(-angle); + } + + /** * Same as scale(s, s, s). */ @@ -3911,6 +3923,11 @@ public class PGraphicsOpenGL extends PGraphics { } + static protected void invScale(PMatrix2D matrix, float x, float y) { + matrix.preApply(1/x, 0, 0, 1/y, 0, 0); + } + + @Override public void shearX(float angle) { float t = (float) Math.tan(angle);