code for circarrow
center
- this is the center of rotation of the arc.
start
- this is the point of initation of the arc and the tail of the arrow
angle
- this is the number of radians the arc will traverse in the counterclockwise direction (negative angles produce clockwise direction)
headscalefactor
- a number which scales the width and length of the head - the factor 1 is a good place to start.
text
- a string (enclosed in grave accents ` ` which is the text that is to label the arrow.
textoffset
- a pair [a,b] which offsets the text from the center of the central radius of the arc "a" units in direction of the central radius and "b" units in the direction orthogonal to the central radius.
textsize
- the point size of the text in TIMES,BOLD font|
colr
- the color of the arc and arrowhead.
>
circarrow:=proc(center,start,
angle,headscalefactor,text,textoffset,textsize,colr)
local arc,dir, HEAD, V1,V2,V3,v1,v2,v3,arccenter,
txt,tmp,rad,shift,head:
tmp:=evalf(start-center):
rad:=sqrt(tmp[1]^2+tmp[2]^2):
shift:=argument(tmp[1]+tmp[2]*I):
if evalf(shift) < 0 then shift:=shift+2*Pi: fi:
arc:=plot({[start],[center],[center[1]+rad*cos(shift+t),
center[2]+rad*sin(shift+t),t=0..angle]},thickness=3,
color=colr):
dir:=.05*rad*(-sin(angle+shift)+I*cos(angle+shift)):
HEAD:=rad*[cos(angle+shift),sin(angle+shift)]+center:
dir:=evalc(dir):
if evalf(angle) <0 then dir:=-dir:fi:
v1:=evalc(dir*(I-1)):v2:=evalc(dir*(-I-1)):v3:=0:
V1:=headscalefactor*[Re(v1),Im(v1)]:
V2:=headscalefactor*[Re(v2),Im(v2)]:
V3:=[Re(v3),Im(v3)]:
arccenter:=center+(rad/2)*[cos(angle/2+shift),
sin(angle/2+shift)]
+textoffset[1]*[cos(angle/2+shift),sin(angle/2+shift)]
+textoffset[2]*[sin(angle/2+shift),-
cos(angle/2+shift)]:
txt:=plots[textplot]([arccenter[1],
arccenter[2],text],font=[TIMES,BOLD,textsize]):
head:=plots[polygonplot]([V1+HEAD,V2+HEAD,V3+HEAD]
,color=colr):
plots[display]({arc,head,txt},scaling=constrained):
end:
>