Revision: 4680
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4680&view=rev
Author: mdboom
Date: 2007-12-10 06:59:49 -0800 (Mon, 10 Dec 2007)
Log Message:
-----------
Use an 8-spline approximation of an ellipse instead of a 4-spline one.
Modified Paths:
--------------
branches/transforms/lib/matplotlib/path.py
Modified: branches/transforms/lib/matplotlib/path.py
===================================================================
--- branches/transforms/lib/matplotlib/path.py 2007-12-10 14:50:40 UTC (rev
4679)
+++ branches/transforms/lib/matplotlib/path.py 2007-12-10 14:59:49 UTC (rev
4680)
@@ -15,8 +15,6 @@
path_in_path, path_intersects_path, convert_path_to_polygons
from matplotlib.cbook import simple_linear_interpolation
-KAPPA = 4.0 * (npy.sqrt(2) - 1) / 3.0
-
class Path(object):
"""
Path represents a series of possibly disconnected, possibly
@@ -350,33 +348,58 @@
def unit_circle(cls):
"""
Returns a Path of the unit circle. The circle is approximated
- using cubic Bezier curves.
+ using cubic Bezier curves. This uses 8 splines around the
+ circle using the approach presented here:
+
+ Lancaster, Don. Approximating a Circle or an Ellipse Using Four
+ Bezier Cubic Splines.
+
+ http://www.tinaja.com/glib/ellipse4.pdf
"""
if cls._unit_circle is None:
- offset = KAPPA
+ MAGIC = 0.2652031
+ SQRT2 = npy.sqrt(0.5)
+ MAGIC45 = npy.sqrt((MAGIC*MAGIC) / 2.0)
+
vertices = npy.array(
- [[-1.0, 0.0],
+ [[0.0, -1.0],
- [-1.0, offset],
- [-offset, 1.0],
- [0.0, 1.0],
+ [MAGIC, -1.0],
+ [SQRT2-MAGIC45, -SQRT2-MAGIC45],
+ [SQRT2, -SQRT2],
- [offset, 1.0],
- [1.0, offset],
- [1.0, 0.0],
+ [SQRT2+MAGIC45, -SQRT2+MAGIC45],
+ [1.0, -MAGIC],
+ [1.0, 0.0],
- [1.0, -offset],
- [offset, -1.0],
- [0.0, -1.0],
+ [1.0, MAGIC],
+ [SQRT2+MAGIC45, SQRT2-MAGIC45],
+ [SQRT2, SQRT2],
- [-offset, -1.0],
- [-1.0, -offset],
- [-1.0, 0.0],
+ [SQRT2-MAGIC45, SQRT2+MAGIC45],
+ [MAGIC, 1.0],
+ [0.0, 1.0],
- [-1.0, 0.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],
+
+ [0.0, -1.0]],
npy.float_)
- codes = cls.CURVE4 * npy.ones(14)
+ codes = cls.CURVE4 * npy.ones(26)
codes[0] = cls.MOVETO
codes[-1] = cls.CLOSEPOLY
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