Commits

Anonymous committed 51907fd

remove orthogonal projection math, replace with rotations

Comments (0)

Files changed (1)

         return pdb.gimp_item_transform_matrix(item, *[coeff for row in matrix for coeff in row])
 
 def orthogonal_projection(img, drawable, a, b, c):
-        m = [[1,0,0], [0,1,0], [0,0,1]]
 
-        if not is_zero(a):
-                if not is_zero(b):
-                        if not is_zero(c):
-                                # a,b,c <> 0
-                                _a = (-1 * b**2 - c**2) / a
-                                _b = (-1 * a**2 - c**2) / b
+        p_xz = sqrt(a**2 + c**2)
+        p = sqrt(a**2 + b**2 + c**2)
 
-                                d = float(a**2 + b**2 + c**2) / a
-                                dbar = float(a**2 - b**2 - c**2) / a
-
-                                e = float(a**2 + b**2 + c**2) / b
-                                ebar = float(b**2 - a**2 - c**2) / b
-
-                                f = a*b - _a*_b
-                                fbar = a*b + _a*_b
-
-                                k = 1.0 / (f*fbar + (c**2)*(a**2 + b**2 + _a**2 + _b**2)+2*(c**4))
-
-                                m = [[-1*k*(f*fbar + (c**2)*d*dbar), -1*k*(c**2)*d*e, 0],[-1*k*(c**2)*d*e,-1*k*(f*fbar + (c**2)*e*ebar),0],[0, 0, 1]]
-                        else:
-                                # c = 0
-                                k = 1.0 / ((a ** 2) + (b ** 2))
-                                m = [[k*(b**2), -1*k*a*b, 0],[-1*k*a*b,k * (a**2),0],[0, 0, 1]]
-                elif not is_zero(c):
-                        # b = 0
-                        m = [[-1.0*(c**2)/ (a**2 + c**2),0, 0],[0,1,0],[0, 0, 1]]
-                else:
-                        # b,c = 0
-                        m = [[0,0,0],[0,1,0],[0,0,1]]
-        elif not is_zero(b):
-                if not is_zero(c):
-                        # a = 0
-                        m = [[1,0,0], [0, float(c**2) /(b**2 + c**2), 0], [0,0,1]]
-                else:
-                        # a,c = 0
-                        m = [[1,0,0],[0,0,0],[0,0,1]]
-        elif not is_zero(c):
-                # a,b = 0
-                m = [[1,0,0],[0,1,0],[0,0,1]]
-        else:
-                # all zeros
-                return None
+        m = [[c/p_xz,0,a/p_xz],[(a**2)/(p_xz*p),p_xz/p,(-1*a*c)/(p_xz*p)],[0,0,1]]
 
         transform(img.active_layer, m)
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.