Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 40f6c93

Browse files
committed
Use numpy for math.
svn path=/branches/transforms/; revision=4723
1 parent f01765f commit 40f6c93

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

lib/matplotlib/path.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -423,25 +423,25 @@ def arc(cls, theta1, theta2, n=None, is_wedge=False):
423423
# http://www.spaceroots.org/documents/ellipse/index.html
424424

425425
# degrees to radians
426-
theta1 *= math.pi / 180.0
427-
theta2 *= math.pi / 180.0
426+
theta1 *= npy.pi / 180.0
427+
theta2 *= npy.pi / 180.0
428428

429-
twopi = math.pi * 2.0
430-
halfpi = math.pi * 0.5
429+
twopi = npy.pi * 2.0
430+
halfpi = npy.pi * 0.5
431431

432-
eta1 = math.atan2(math.sin(theta1), math.cos(theta1))
433-
eta2 = math.atan2(math.sin(theta2), math.cos(theta2))
434-
eta2 -= twopi * math.floor((eta2 - eta1) / twopi)
435-
if (theta2 - theta1 > math.pi) and (eta2 - eta1 < math.pi):
432+
eta1 = npy.arctan2(npy.sin(theta1), npy.cos(theta1))
433+
eta2 = npy.arctan2(npy.sin(theta2), npy.cos(theta2))
434+
eta2 -= twopi * npy.floor((eta2 - eta1) / twopi)
435+
if (theta2 - theta1 > npy.pi) and (eta2 - eta1 < npy.pi):
436436
eta2 += twopi
437437

438438
# number of curve segments to make
439439
if n is None:
440-
n = int(2 ** math.ceil((eta2 - eta1) / halfpi))
440+
n = int(2 ** npy.ceil((eta2 - eta1) / halfpi))
441441

442442
deta = (eta2 - eta1) / n
443-
t = math.tan(0.5 * deta)
444-
alpha = math.sin(deta) * (math.sqrt(4.0 + 3.0 * t * t) - 1) / 3.0
443+
t = npy.tan(0.5 * deta)
444+
alpha = npy.sin(deta) * (npy.sqrt(4.0 + 3.0 * t * t) - 1) / 3.0
445445

446446
steps = npy.linspace(eta1, eta2, n + 1, True)
447447
cos_eta = npy.cos(steps)

0 commit comments

Comments
 (0)