Dear list,
I want to draw paths between points which are bent by a certain angle.
The code in the MWE below works well but I was thinking that the expert
here can surely improve it and suggest a nicer syntax.
Cheers, Henri
---
\startMPpage
vardef bend(expr a,b,phi) =
a{dir(angle(b-a)+phi)} .. {dir(angle(a-b)+180-phi)}b
enddef ;
z1 = (-.5cm,1cm) ;
z2 = (1cm,3cm) ;
for phi = 0 step 5 until 360:
draw bend(z1,z2,phi) withcolor (phi/360)[red,blue] ;
endfor ;
\stopMPpage
Possible use case:
\startMPpage[offset=1cm]
vardef bend(expr a,b,phi) =
a{dir(angle(b-a)+phi)} .. {dir(angle(a-b)+180-phi)}b
enddef ;
z1 = (-.5cm,1cm) ;
z2 = (1cm,3cm) ;
draw z1 -- z2 ;
dotlabel.lft("$-$", z1) ;
dotlabel.lft("$+$", z2) ;
path p; p := bend(z1,z2,-30) ;
drawdblarrow p withcolor blue ;
label.lrt(textext("$\Delta$"),point .5 along p) withcolor blue ;
\stopMPpage