[gegl] matrix3: make gegl_matrix3_transform_point support perspective transforms



commit 48df5d423324819b09e5128092c88f05f68f1dd3
Author: Ãyvind KolÃs <pippin gimp org>
Date:   Thu Mar 22 02:23:50 2012 +0000

    matrix3: make gegl_matrix3_transform_point support perspective transforms
    
    The affine op uses this function to determine the bounding box of what needs
    to be defined on the source pads. This should permit the affine op to work
    for GIMPs needs, perhaps the whole op should be renamed to transform now?

 gegl/gegl-matrix.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/gegl/gegl-matrix.c b/gegl/gegl-matrix.c
index 2b191a0..4355313 100644
--- a/gegl/gegl-matrix.c
+++ b/gegl/gegl-matrix.c
@@ -215,12 +215,12 @@ gegl_matrix3_transform_point (GeglMatrix3  *matrix,
                               gdouble     *x,
                               gdouble     *y)
 {
-  gdouble xp,
-          yp;
+  gdouble xp, yp, w;
+  
+  w = (*x * matrix->coeff [2][0] + *y * matrix->coeff [2][1] + matrix->coeff [2][2]);
 
-  /* assumes last row is [0 0 1] (true for affine transforms) */
-  xp = *x * matrix->coeff [0][0] + *y * matrix->coeff [0][1] + matrix->coeff [0][2];
-  yp = *x * matrix->coeff [1][0] + *y * matrix->coeff [1][1] + matrix->coeff [1][2];
+  xp = (*x * matrix->coeff [0][0] + *y * matrix->coeff [0][1] + matrix->coeff [0][2]) /w;
+  yp = (*x * matrix->coeff [1][0] + *y * matrix->coeff [1][1] + matrix->coeff [1][2]) /w;
 
   *x = xp;
   *y = yp;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]