summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/asymptote/plain_arcs.asy
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-04-07 18:19:31 +0000
committerKarl Berry <karl@freefriends.org>2013-04-07 18:19:31 +0000
commit752012c605d34cd943795527a9738475a6958fcc (patch)
tree4ee06acdd8333a662c2d6f6ef716235053468f55 /Master/texmf-dist/asymptote/plain_arcs.asy
parent9789d09132f18a838e84f041b4b3aff28d3426ec (diff)
texmf -> texmf-dist: start with unique dirs from texmf
git-svn-id: svn://tug.org/texlive/trunk@29712 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/asymptote/plain_arcs.asy')
-rw-r--r--Master/texmf-dist/asymptote/plain_arcs.asy44
1 files changed, 44 insertions, 0 deletions
diff --git a/Master/texmf-dist/asymptote/plain_arcs.asy b/Master/texmf-dist/asymptote/plain_arcs.asy
new file mode 100644
index 00000000000..140bc3cff19
--- /dev/null
+++ b/Master/texmf-dist/asymptote/plain_arcs.asy
@@ -0,0 +1,44 @@
+bool CCW=true;
+bool CW=false;
+
+path circle(pair c, real r)
+{
+ return shift(c)*scale(r)*unitcircle;
+}
+
+path ellipse(pair c, real a, real b)
+{
+ return shift(c)*scale(a,b)*unitcircle;
+}
+
+// return an arc centered at c from pair z1 to z2 (assuming |z2-c|=|z1-c|),
+// drawing in the given direction.
+path arc(pair c, explicit pair z1, explicit pair z2, bool direction=CCW)
+{
+ z1 -= c;
+ real r=abs(z1);
+ z1=unit(z1);
+ z2=unit(z2-c);
+
+ real t1=intersect(unitcircle,(0,0)--2*z1)[0];
+ real t2=intersect(unitcircle,(0,0)--2*z2)[0];
+ static int n=length(unitcircle);
+ if(direction) {
+ if (t1 >= t2) t1 -= n;
+ } else if(t2 >= t1) t2 -= n;
+ return shift(c)*scale(r)*subpath(unitcircle,t1,t2);
+}
+
+// return an arc centered at c with radius r from angle1 to angle2 in degrees,
+// drawing in the given direction.
+path arc(pair c, real r, real angle1, real angle2, bool direction)
+{
+ return arc(c,c+r*dir(angle1),c+r*dir(angle2),direction);
+}
+
+// return an arc centered at c with radius r > 0 from angle1 to angle2 in
+// degrees, drawing counterclockwise if angle2 >= angle1 (otherwise clockwise).
+path arc(pair c, real r, real angle1, real angle2)
+{
+ return arc(c,r,angle1,angle2,angle2 >= angle1 ? CCW : CW);
+}