Revision: 4688
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4688&view=rev
Author:   mdboom
Date:     2007-12-10 08:17:42 -0800 (Mon, 10 Dec 2007)

Log Message:
-----------
Merged revisions 4669-4682 via svnmerge from 
http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib

........
  r4670 | mdboom | 2007-12-07 14:18:58 -0500 (Fri, 07 Dec 2007) | 2 lines
  
  Updating CHANGELOG.
........
  r4679 | mdboom | 2007-12-10 09:50:40 -0500 (Mon, 10 Dec 2007) | 2 lines
  
  Use an 8-spline approximation of an ellipse instead of a 4-spline one.
........

Modified Paths:
--------------
    branches/transforms/CHANGELOG
    branches/transforms/lib/matplotlib/backends/backend_ps.py
    branches/transforms/lib/matplotlib/patches.py

Added Paths:
-----------
    branches/transforms/unit/ellipse_large.py

Property Changed:
----------------
    branches/transforms/


Property changes on: branches/transforms
___________________________________________________________________
Name: svnmerge-integrated
   - /trunk/matplotlib:1-4668
   + /trunk/matplotlib:1-4682

Modified: branches/transforms/CHANGELOG
===================================================================
--- branches/transforms/CHANGELOG       2007-12-10 16:17:16 UTC (rev 4687)
+++ branches/transforms/CHANGELOG       2007-12-10 16:17:42 UTC (rev 4688)
@@ -1,3 +1,5 @@
+2007-12-07 Issue a warning when drawing an image on a non-linear axis. - MGD
+
 2007-12-06 let widgets.Cursor initialize to the lower x and y bounds
            rather than 0,0, which can cause havoc for dates and other
            transforms - DSD
@@ -6,6 +8,10 @@
 
 2007-12-06 fixed a bug in rcsetup, see bug 1845057 - DSD
 
+2007-12-05 Fix how fonts are cached to avoid loading the same one multiple 
times.
+           (This was a regression since 0.90 caused by the refactoring of
+           font_manager.py) - MGD
+
 ===============================================================
 2007-11-27 Released 0.91.1 at revision 4517
 

Modified: branches/transforms/lib/matplotlib/backends/backend_ps.py
===================================================================
--- branches/transforms/lib/matplotlib/backends/backend_ps.py   2007-12-10 
16:17:16 UTC (rev 4687)
+++ branches/transforms/lib/matplotlib/backends/backend_ps.py   2007-12-10 
16:17:42 UTC (rev 4688)
@@ -1430,4 +1430,31 @@
       clip
       newpath
     } bind def""",
+<<<<<<< .working
+=======
+    # angle1 angle2 rx ry x y  *ellipse*  -
+    """/ellipse {
+      newpath
+      matrix currentmatrix 7 1 roll
+      translate
+      scale
+      0 0 1 5 3 roll arc
+      setmatrix
+      closepath
+    } bind def""",
+    """/unitcircle {
+    newpath
+0. -1. moveto
+0.2652031 -1.0 0.519579870785 -0.894633691588 0.707106781187 -0.707106781187 
curveto
+0.894633691588 -0.519579870785 1.0 -0.2652031 1.0 0.0 curveto
+1.0 0.2652031 0.894633691588 0.519579870785 0.707106781187 0.707106781187 
curveto
+0.519579870785 0.894633691588 0.2652031 1.0 0.0 1.0 curveto
+-0.2652031 1.0 -0.519579870785 0.894633691588 -0.707106781187 0.707106781187 
curveto
+-0.894633691588 0.519579870785 -1.0 0.2652031 -1.0 0.0 curveto
+-1.0 -0.2652031 -0.894633691588 -0.519579870785 -0.707106781187 
-0.707106781187 curveto
+-0.519579870785 -0.894633691588 -0.2652031 -1.0 0.0 -1.0 curveto
+closepath
+    } bind def""",
+
+>>>>>>> .merge-right.r4679
 ]

Modified: branches/transforms/lib/matplotlib/patches.py
===================================================================
--- branches/transforms/lib/matplotlib/patches.py       2007-12-10 16:17:16 UTC 
(rev 4687)
+++ branches/transforms/lib/matplotlib/patches.py       2007-12-10 16:17:42 UTC 
(rev 4688)
@@ -820,6 +820,49 @@
     """
     A scale-free ellipse
     """
+<<<<<<< .working
+=======
+    MAGIC = 0.2652031
+    SQRT2 = npy.sqrt(0.5)
+    MAGIC45 = npy.sqrt((MAGIC*MAGIC) / 2.0)
+
+    circle = npy.array(
+        [[0.0, -1.0],
+
+         [MAGIC, -1.0],
+         [SQRT2-MAGIC45, -SQRT2-MAGIC45],
+         [SQRT2, -SQRT2],
+
+         [SQRT2+MAGIC45, -SQRT2+MAGIC45],
+         [1.0, -MAGIC],
+         [1.0, 0.0],
+
+         [1.0, MAGIC],
+         [SQRT2+MAGIC45, SQRT2-MAGIC45],
+         [SQRT2, SQRT2],
+
+         [SQRT2-MAGIC45, SQRT2+MAGIC45],
+         [MAGIC, 1.0],
+         [0.0, 1.0],
+
+         [-MAGIC, 1.0],
+         [-SQRT2+MAGIC45, SQRT2+MAGIC45],
+         [-SQRT2, SQRT2],
+
+         [-SQRT2-MAGIC45, SQRT2-MAGIC45],
+         [-1.0, MAGIC],
+         [-1.0, 0.0],
+
+         [-1.0, -MAGIC],
+         [-SQRT2-MAGIC45, -SQRT2+MAGIC45],
+         [-SQRT2, -SQRT2],
+
+         [-SQRT2+MAGIC45, -SQRT2-MAGIC45],
+         [-MAGIC, -1.0],
+         [0.0, -1.0]],
+        npy.float_)
+
+>>>>>>> .merge-right.r4679
     def __str__(self):
         return 
"Ellipse(%d,%d;%dx%d)"%(self.center[0],self.center[1],self.width,self.height)
 
@@ -855,10 +898,17 @@
     def get_patch_transform(self):
         return self._patch_transform
 
+<<<<<<< .working
     def contains(self,ev):
         if ev.x is None or ev.y is None: return False,{}
         x, y = self.get_transform().inverted().transform_point((ev.x, ev.y))
         return (x*x + y*y) <= 1.0, {}
+=======
+        xcenter = self.convert_xunits(xcenter)
+        width = self.convert_xunits(width)
+        ycenter = self.convert_yunits(ycenter)
+        height = self.convert_xunits(height)
+>>>>>>> .merge-right.r4679
 
     def _get_center(self):
         return self._center
@@ -882,6 +932,105 @@
     angle = property(_get_angle, _set_angle)
 
 
+<<<<<<< .working
+=======
+        rtheta = angle*npy.pi/180.
+        R = npy.array([
+            [npy.cos(rtheta),  -npy.sin(rtheta)],
+            [npy.sin(rtheta), npy.cos(rtheta)],
+            ])
+
+
+        x, y = npy.dot(R, npy.array([x, y]))
+        x += xcenter
+        y += ycenter
+
+        return zip(x, y)
+
+    def draw(self, renderer):
+        if not self.get_visible(): return
+        #renderer.open_group('patch')
+        gc = renderer.new_gc()
+        gc.set_foreground(self._edgecolor)
+        gc.set_linewidth(self._linewidth)
+        gc.set_alpha(self._alpha)
+        gc.set_antialiased(self._antialiased)
+        self._set_gc_clip(gc)
+
+        gc.set_capstyle('projecting')
+
+        if not self.fill or self._facecolor is None: rgbFace = None
+        else: rgbFace = colors.colorConverter.to_rgb(self._facecolor)
+
+        if self._hatch:
+            gc.set_hatch(self._hatch )
+
+
+        if not hasattr(renderer, 'draw_path'):
+            mpl.verbose.report('patches.Ellipse renderer does not support path 
drawing; falling back on vertex approximation for nonlinear transformation')
+            renderer.draw_polygon(gc, rgbFace, self.get_verts())
+            return
+
+
+        x, y = self.center
+        x = self.convert_xunits(x)
+        y = self.convert_yunits(y)
+        w = self.convert_xunits(self.width)/2.
+        h = self.convert_yunits(self.height)/2.
+
+        theta = self.angle * npy.pi/180.
+        T = npy.array([
+            [1, 0, x],
+            [0, 1, y],
+            [0, 0, 1]])
+
+
+
+
+        S = npy.array([
+            [w, 0, 0],
+            [0, h, 0],
+            [0, 0, 1]])
+
+
+
+        # rotate by theta
+        R = npy.array([
+            [npy.cos(theta),  -npy.sin(theta), 0],
+            [npy.sin(theta), npy.cos(theta), 0],
+            [0,           0,          1]])
+
+        # transform unit circle into ellipse
+        E = npy.dot(T, npy.dot(R, S))
+
+
+        # Apply the display affine
+        sx, b, c, sy, tx, ty = self.get_transform().as_vec6_val()
+
+        # display coords
+        D = npy.array([
+            [sx, b, tx],
+            [c, sy, ty],
+            [0, 0, 1]], npy.float_)
+
+        M = npy.dot(D,E)
+
+        C = npy.ones((3, len(self.circle)))
+        C[0:2,:] = self.circle.T
+
+        ellipse = npy.dot(M, C).T[:,:2]
+
+        path =  agg.path_storage()
+        path.move_to(*ellipse[0])
+        for i in range(1, 25, 3):
+            path.curve4(*ellipse[i:i+3].flat)
+        path.close_polygon()
+
+        renderer.draw_path(gc, rgbFace, path)
+
+
+>>>>>>> .merge-right.r4679
+
 class Circle(Ellipse):
     """
     A circle patch

Copied: branches/transforms/unit/ellipse_large.py (from rev 4679, 
trunk/matplotlib/unit/ellipse_large.py)
===================================================================
--- branches/transforms/unit/ellipse_large.py                           (rev 0)
+++ branches/transforms/unit/ellipse_large.py   2007-12-10 16:17:42 UTC (rev 
4688)
@@ -0,0 +1,107 @@
+
+# This example can be boiled down to a more simplistic example
+# to show the problem, but bu including the upper and lower
+# bound ellipses, it demonstrates how significant this error
+# is to our plots.
+
+import math
+from pylab import *
+from matplotlib.patches import Ellipse
+
+# given a point x, y
+x = 2692.440
+y = 6720.850
+
+# get is the radius of a circle through this point
+r = math.sqrt( x*x+y*y )
+
+# show some comparative circles
+delta = 6
+
+
+##################################################
+def custom_ellipse( ax, x, y, major, minor, theta, numpoints = 750, **kwargs ):
+   xs = []
+   ys = []
+   incr = 2.0*math.pi / numpoints
+   incrTheta = 0.0
+   while incrTheta <= (2.0*math.pi):
+      a = major * math.cos( incrTheta )
+      b = minor * math.sin( incrTheta )
+      l = math.sqrt( ( a**2 ) + ( b**2 ) )
+      phi = math.atan2( b, a )
+      incrTheta += incr
+
+      xs.append( x + ( l * math.cos( theta + phi ) ) )
+      ys.append( y + ( l * math.sin( theta + phi ) ) )
+   # end while
+
+   incrTheta = 2.0*math.pi
+   a = major * math.cos( incrTheta )
+   b = minor * math.sin( incrTheta )
+   l = sqrt( ( a**2 ) + ( b**2 ) )
+   phi = math.atan2( b, a )
+   xs.append( x + ( l * math.cos( theta + phi ) ) )
+   ys.append( y + ( l * math.sin( theta + phi ) ) )
+
+   ellipseLine = ax.plot( xs, ys, **kwargs )
+
+
+##################################################
+# make the axes
+ax = subplot( 211, aspect='equal' )
+ax.set_aspect( 'equal', 'datalim' )
+
+# make the lower-bound ellipse
+diam = (r - delta) * 2.0
+lower_ellipse = Ellipse( (0.0, 0.0), diam, diam, 0.0, fill=False, 
edgecolor="darkgreen" )
+ax.add_patch( lower_ellipse )
+
+# make the target ellipse
+diam = r * 2.0
+target_ellipse = Ellipse( (0.0, 0.0), diam, diam, 0.0, fill=False, 
edgecolor="darkred" )
+ax.add_patch( target_ellipse )
+
+# make the upper-bound ellipse
+diam = (r + delta) * 2.0
+upper_ellipse = Ellipse( (0.0, 0.0), diam, diam, 0.0, fill=False, 
edgecolor="darkblue" )
+ax.add_patch( upper_ellipse )
+
+# make the target
+diam = delta * 2.0
+target = Ellipse( (x, y), diam, diam, 0.0, fill=False, edgecolor="#DD1208" )
+ax.add_patch( target )
+
+# give it a big marker
+ax.plot( [x], [y], marker='x', linestyle='None', mfc='red', mec='red', 
markersize=10 )
+
+##################################################
+# now lets do the same thing again using a custom ellipse function
+
+# make the axes
+ax = subplot( 212, aspect='equal', sharex=ax, sharey=ax )
+ax.set_aspect( 'equal', 'datalim' )
+
+# make the lower-bound ellipse
+custom_ellipse( ax, 0.0, 0.0, r-delta, r-delta, 0.0, color="darkgreen" )
+
+# make the target ellipse
+custom_ellipse( ax, 0.0, 0.0, r, r, 0.0, color="darkred" )
+
+# make the upper-bound ellipse
+custom_ellipse( ax, 0.0, 0.0, r+delta, r+delta, 0.0, color="darkblue" )
+
+# make the target
+custom_ellipse( ax, x, y, delta, delta, 0.0, color="#BB1208" )
+
+# give it a big marker
+ax.plot( [x], [y], marker='x', linestyle='None', mfc='red', mec='red', 
markersize=10 )
+
+##################################################
+# lets zoom in to see the area of interest
+
+ax.set_xlim(2650, 2735)
+ax.set_ylim(6705, 6735)
+show()
+
+savefig("ellipse")


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
SF.Net email is sponsored by: 
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to