The Curly Brace made with Asymptote
by Klaus-Anton, Jun 22, 2024, 8:43 AM
On the home forum of asy you find #45 Draw braces by Charles Staats.
It needs two pairs as argument. Look here:
From the midpoint of the two pairs it goes perpendicular from the segment building pair (which i call here
and
) to the together point (which i call here
).
The length - in the code denoted as a real named amplitude - from
to
is calculated by multiplying the
with a factor called defaultratio (which has been preset to the real value
).
You see that these curly braces have over the whole path the same linethickness. This is in contrast to the curly braces you are normally used to see in
, which imitates typographically a 3D effect.
Note:
Labeling with the help of curly braces is an alternative to the - also not so bad - distance feature of geometry.asy. The last invokes eventually unwhished autosizings, which - untill now - i do not really know how to suppress. (Perhaps with frames?)
Edit 2024-07-02
In Asymptote Home Forum From 2D to 3D there is a nice 3D-curly-brace. But the there presented code does not run in it's last part, so i commented it me out. It is nice to see if you run it on the Asymptote Web Application.
modified code
It needs two pairs as argument. Look here:
![[asy]
real innerangle = radians(60);
real outerangle = radians(70);
real midangle = radians(0);
private real defaultratio = .14;
path brace(pair a, pair b, real amplitude = defaultratio*length(b-a)) {
transform t = identity();
real length = length(b-a);
real sign = (amplitude < 0 ? -1 : 1);
path brace;
if (abs(amplitude) < defaultratio*length) {
real slope = 2*defaultratio;
real controldist = (abs(amplitude)/2) / slope;
brace = (0,0){expi(sign*outerangle)} :: {expi(sign*midangle)}(controldist, amplitude/2) :: {expi(sign*midangle)} (length/2 - controldist,amplitude/2) :: {expi(sign*innerangle)} (length/2, amplitude) {expi(-sign*innerangle)} :: {expi(-sign*midangle)} (length/2 + controldist, amplitude/2) :: {expi(-sign*midangle)} (length-controldist, amplitude/2) :: {expi(-sign*outerangle)} (length,0);
} else {
brace = (0,0){expi(sign*outerangle)} ::
{expi(sign*midangle)}(length/4, amplitude/2)
:: {expi(sign*innerangle)} (length/2, amplitude)
{expi(-sign*innerangle)}
:: {expi(-sign*midangle)}(3*length/4, amplitude/2) ::
{expi(-sign*outerangle)} (length,0);
}
real angle = degrees(atan2((b-a).y, (b-a).x));
t = rotate(angle)*t;
t = shift(a) * t;
return t * brace;
}
pair A=(0,0),B=(1,0)
,mpAB=midpoint(A--B)
,C=(mpAB.x,length(B-A)*defaultratio);
draw(mpAB--C,blue);
draw(brace(A,B));
draw(A--B,red);
label("$A$",A,S,red);
label("$B$",B,S,red);
label("$\texttt{mp}AB$",mpAB,S,blue);
label("$C$",C,N,blue);
shipout(bbox(2mm,FillDraw(white,white)));
[/asy]](http://latex.artofproblemsolving.com/5/f/a/5fac5f0ddf3202caadca2ac7a72573b38777d09a.png)
Figure 1: Curly Brace made with asy
From the midpoint of the two pairs it goes perpendicular from the segment building pair (which i call here



The length - in the code denoted as a real named amplitude - from




You see that these curly braces have over the whole path the same linethickness. This is in contrast to the curly braces you are normally used to see in

![[asy]
unitsize(1cm);
real a=3,b=2,c=sqrt(5),p=b^2/a;
pair center=origin, F1=(c,0), F2=(-c,0);
pair vertex1=(a,0),V1=vertex1,vertex2=(-a,0),V2=vertex2;
pair co_vertex1=(0,b), co_vertex2=(0,-b);
pair CoV1=co_vertex1;
pair CoV2=co_vertex2;
draw(center--F1//--co_vertex1--cycle
^^center--co_vertex1
^^center--co_vertex2
^^center--vertex2
^^F1--(F1.x,F1.y-p)
);
draw(scale(a,b)*circle((0,0),1),blue);
dot(center
^^F1^^vertex1^^co_vertex1
^^F2^^vertex2^^co_vertex2
);
//draw(circle(F1,a));
dot(F1^^F2,red);
label("$F_2$",F2,N,red);
label("$F_1$",F1,N,red);
label("$p$",midpoint(F1--(F1.x,F1.y-p)),.8E);
//\makebox(Breite2,Höhe)[Anordnung2]{Text}
label("$\underbrace{\makebox[2.125cm]{\phantom{}}}$",(1.125,-.2));
//label("$c$",(1.125,0),3S);
label("$e_{\scriptsize\textrm{lin}}$",(1.125,0),3S);
label("$\underbrace{\makebox[2.875cm]{\phantom{}}}$",(-.5*a,-.2));
label("$a$",(-.5*a,-.2),1.5S);
label(rotate(-90)*"$\underbrace{\makebox[1.875cm]{\phantom{}}}$",(-.2,.5b));
label("$b$",(-.2,.5b),1.5W);
label("$V_1$",V1,E);
label("$V_2$",V2,W);
label("$\textrm{Co\kern2pt-}V_1$",CoV1,N);
label("$\textrm{Co\kern2pt-}V_2$",CoV2,S);
shipout(bbox(2mm,FillDraw(white,white)));
[/asy]](http://latex.artofproblemsolving.com/f/e/3/fe3a3a5e077aa994b7a37c65e28e867166bef168.png)
Figure 2: Curly Braces made with
and used in asy

And compare: Klaus-Anton's blog Ellipse with a=3 and b=2 and AoPS-wiki Conic section and too AoPS-wiki Ellipse
Note:
Labeling with the help of curly braces is an alternative to the - also not so bad - distance feature of geometry.asy. The last invokes eventually unwhished autosizings, which - untill now - i do not really know how to suppress. (Perhaps with frames?)
Edit 2024-07-02
In Asymptote Home Forum From 2D to 3D there is a nice 3D-curly-brace. But the there presented code does not run in it's last part, so i commented it me out. It is nice to see if you run it on the Asymptote Web Application.
modified code
//http://asymptote.ualberta.ca/
import three;
typedef triple plane(pair p);
plane Plane(triple a, triple b, triple c)
{
return new triple(pair p) { return xpart(p)*a + ypart(p)*b + c; };
}
plane XYPlane=Plane((1,0,0),(0,1,0),(0,0,0));
plane YXPlane=Plane((0,1,0),(1,0,0),(0,0,0));
plane XZPlane=Plane((1,0,0),(0,0,1),(0,0,0));
plane ZXPlane=Plane((0,0,1),(1,0,0),(0,0,0));
plane YZPlane=Plane((0,1,0),(0,0,1),(0,0,0));
plane ZYPlane=Plane((0,0,1),(0,1,0),(0,0,0));
path3 path3(path g, plane plane=XYPlane)
{
if(length(g)==0) return nullpath3;
guide3 g3=plane(point(g,0));
for(int i=1; i<=length(g); ++i)
{
if(i==length(g)&&(cyclic(g))) g3=g3..controls plane(postcontrol(g,i-1)) and plane(precontrol(g,i))..cycle;
else g3=g3..controls plane(postcontrol(g,i-1)) and plane(precontrol(g,i))..plane(point(g,i));
}
return g3;
}
// Testcase
size(5cm,5cm);
draw(path3((0,0)--(5,0),XYPlane));
draw(path3((0,0)--(5,0),YZPlane));
draw(path3((0,0)--(5,0),ZXPlane));
guide g=(0,0){dir(30)}..(2,1)..(3,0)..{curl(0)}(4,1)--(2,2);
draw(path3(g,XYPlane));
draw(path3(g,YXPlane));
draw(path3(g,XZPlane));
draw(path3(g,ZXPlane));
draw(path3(g,YZPlane));
draw(path3(g,ZYPlane));
/*
workspace_1.asy: 45.9: no matching function 'filldraw(path3, pen)'
guide c=(2,2)..(3,2)..(2,3)..cycle;
filldraw(path3(c,XYPlane),lightred);
filldraw(path3(c,YZPlane),lightred);
filldraw(path3(c,ZXPlane),lightred);
*/
![[asy]
import three;
typedef triple plane(pair p);
plane Plane(triple a, triple b, triple c)
{
return new triple(pair p) { return xpart(p)*a + ypart(p)*b + c; };
}
plane XYPlane=Plane((1,0,0),(0,1,0),(0,0,0));
plane YXPlane=Plane((0,1,0),(1,0,0),(0,0,0));
plane XZPlane=Plane((1,0,0),(0,0,1),(0,0,0));
plane ZXPlane=Plane((0,0,1),(1,0,0),(0,0,0));
plane YZPlane=Plane((0,1,0),(0,0,1),(0,0,0));
plane ZYPlane=Plane((0,0,1),(0,1,0),(0,0,0));
path3 path3(path g, plane plane=XYPlane)
{
if(length(g)==0) return nullpath3;
guide3 g3=plane(point(g,0));
for(int i=1; i<=length(g); ++i)
{
if(i==length(g)&&(cyclic(g))) g3=g3..controls plane(postcontrol(g,i-1)) and plane(precontrol(g,i))..cycle;
else g3=g3..controls plane(postcontrol(g,i-1)) and plane(precontrol(g,i))..plane(point(g,i));
}
return g3;
}
// Testcase
size(5cm,5cm);
draw(path3((0,0)--(5,0),XYPlane));
draw(path3((0,0)--(5,0),YZPlane));
draw(path3((0,0)--(5,0),ZXPlane));
guide g=(0,0){dir(30)}..(2,1)..(3,0)..{curl(0)}(4,1)--(2,2);
draw(path3(g,XYPlane));
draw(path3(g,YXPlane));
draw(path3(g,XZPlane));
draw(path3(g,ZXPlane));
draw(path3(g,YZPlane));
draw(path3(g,ZYPlane));
// /*
//workspace_1.asy: 45.9: no matching function 'filldraw(path3, pen)'
guide c=(2,2)..(3,2)..(2,3)..cycle;
//draw(path3(c,XYPlane),lightred);
//draw(path3(c,YZPlane),lightred);
//draw(path3(c,ZXPlane),lightred);
draw(c,red);
draw(rotate(90)*c,red);
draw(rotate(2.5*90)*c,red);
// */
shipout(bbox(2mm, FillDraw(white,white)));
[/asy]](http://latex.artofproblemsolving.com/3/3/f/33f5252a4d67412596d586096788d8be64a01fcc.png)
Figure 3: Curly Braces in 3D. - A Flower does appear in the Center.
This post has been edited 12 times. Last edited by Klaus-Anton, Jul 2, 2024, 5:38 PM