         //
         // Since we're matching height we only care about (2) 
 
-        const b:Number = matrix.b;
-        const d:Number = matrix.d;
+        var b:Number = matrix.b;
+        var d:Number = matrix.d;
+        
+        // If components are very close to zero, zero them out to handle the special cases
+        if (-1.0e-9 < b && b < +1.0e-9)
+            b = 0;
+        if (-1.0e-9 < d && d < +1.0e-9)
+            d = 0;
 
         // Handle special cases first
         if (b == 0)

        // (2) h = abs( bx + d1y )
        // 

        const a:Number = matrix.a;
        const b:Number = matrix.b;
        const c:Number = matrix.c;
        const d:Number = matrix.d;

        // Handle special cases.
        if (b == 0 && c == 0)

        {
            // No solution in the following cases since the matrix collapses
            // all points into a line.
            if (b == 0 || c == 0)
               return null;

            // (1) w = abs( ax + cy ) <=> w = abs( cy ) <=> w = abs(c)y
