## Asymptote using geometry.asy – fig0170

Category: Asymptote,Examples 2D,geometry.asyPh. Ivaldi @ 22 h 02 min

 (Compiled with Asymptote version 2.14svn-r5318)

unitsize(1cm);
import geometry;
dotfactor*=1.5;
linemargin=5mm;

// currentcoordsys=cartesiansystem((2,1),i=(1,0.5),j=(-1,1));
show(currentcoordsys);

point A=(-3,-1), B=(3,4);
line l1=line(A,B);

draw(l1,red);
dot("$A$",A,SE);
dot("$B$",B,NW);

point M=(2,-2);
dot("$M$",M);

/* View the definition of line parallel(point,line) */
draw(parallel(M,l1),red);

/* View the definition of line perpendicular(point,line) */
line perp=perpendicular(M,l1);
draw(perp);

/* View the definition of point intersectionpoint(line,line) */
point interp=intersectionpoint(l1,perp);
dot(interp,green);

/* View the definition of void markrightangle(picture,point,point,point,real,pen,margin,filltype) */
markrightangle(l1.A,interp,rotate(180,interp)*M,size=5mm);

draw(box((-5,-5),(5,5)),invisible);



Étiquettes : , , , , , , ,

## Asymptote using geometry.asy – fig0210

Category: Asymptote,Examples 2D,geometry.asyPh. Ivaldi @ 2 h 02 min

 (Compiled with Asymptote version 2.14svn-r5318)

size(12cm);
import geometry;

currentcoordsys=cartesiansystem((2,1),i=(1,0.5),j=(-0.25,1));
show(currentcoordsys);

point A=(1,1);
line l1=line(45,A);
draw("$(l_1)$",l1);
dot("$A$",A);

point B=(3,1);
line l2=line(-60,B);
draw("$(l_2)$",l2);
dot("$B$",B);

/* View the definition of void markangle(picture,Label,int,real,real,line,line,arrowbar,pen,filltype,margin,marker) */
markangle(2,l2,l1,0.8*green,StickIntervalMarker(i=1,n=2));

l2,l1,0.8*blue);

markangle(reverse(l2),reverse(l1),Arrow,StickIntervalMarker(i=1,n=2));

/* View the definition of real sharpdegrees(line,line) */
markangle((string) sharpdegrees(l2,l1),
reverse(l2),l1,Arrow,red);



Étiquettes : , , ,

## Asymptote using geometry.asy – fig0220

Category: Asymptote,Examples 2D,geometry.asyPh. Ivaldi @ 3 h 02 min

 (Compiled with Asymptote version 2.14svn-r5318)

unitsize(2cm);
import geometry;

currentcoordsys=cartesiansystem((2,1),i=(1,0.25),j=(-0.25,.75));
show(lo=Label("$O$",align=SE+0.5E), currentcoordsys);

pair A=(1,1), B=(2,2);
line l1=line(A,B);
draw("$(l_1)$",l1);

line l2=rotate(100,(3,3))*l1;
draw("$(l_2)$",l2);
write(locate(intersectionpoint(l1,l2)));
/* View the definition of line bisector(line,line,real,bool) */
line bis=bisector(l1,l2);
draw(bis);

line Bis=bisector(l1,l2,90);
draw(Bis,0.8*red);

/* View the definition of void markangle(picture,Label,int,real,real,line,line,arrowbar,pen,filltype,margin,marker) */
markangle(2, l1, l2, StickIntervalMarker(2,2,true));

/* View the definition of bool concurrent(...line[]) */
if (concurrent(bis,l1,l2,Bis)) label("Concurrent",(3,3), dir(135));

draw(box(locate((-1,0)),locate((5,5))),invisible);



Étiquettes : , , , ,

## Asymptote using geometry.asy – fig0820

Category: Asymptote,Examples 2D,geometry.asyPh. Ivaldi @ 15 h 02 min

 (Compiled with Asymptote version 2.14svn-r5318)

import geometry;
size(8cm,0);

// currentcoordsys=cartesiansystem((1,2),i=(1,0.5),j=(-0.5,.75));
show(currentcoordsys, xpen=invisible);

point A=(1,1);
dot("$A$",A,S,red);

real R=2;
arc C=arc(circle(A,R), 45, 210);
draw(C,linewidth(4mm));

/* View the definition of void markarc(picture,Label,int,real,real,arc,arrowbar,pen,pen,margin,marker) */
markarc(format("%0g",degrees(C)), C, Arrow);

/* View the definition of arc *(real, explicit arc) */
draw(0.5*C,2mm+yellow);

arc Cp=C/3;
draw(Cp,1mm+blue);



Étiquettes : , , , ,

## Asymptote using geometry.asy – fig0830

Category: Asymptote,Examples 2D,geometry.asyPh. Ivaldi @ 16 h 02 min

 (Compiled with Asymptote version 2.14svn-r5318)

import geometry;
size(8cm,0);

// currentcoordsys=cartesiansystem((1,2),i=(1,0.5),j=(-0.5,.75));
show(currentcoordsys, xpen=invisible);

point A=(1,1);
dot("$A$", A, NW, red);

real R=2;
arc C=arc(circle(A,R), 45, 210, CW);
draw(C,linewidth(4mm));

/* View the definition of void markarc(picture,Label,int,real,real,arc,arrowbar,pen,pen,margin,marker) */

/* View the definition of arc *(real, explicit arc) */
draw(0.5*C, 2mm+yellow);

arc Cp=C/3;
draw(Cp, 1mm+blue);



Étiquettes : , , , ,

## Asymptote using geometry.asy – fig0840

Category: Asymptote,Examples 2D,geometry.asyPh. Ivaldi @ 17 h 02 min

 (Compiled with Asymptote version 2.14svn-r5318)

import geometry;
size(8cm,0);

// currentcoordsys=cartesiansystem((1,2),i=(1,0.5),j=(-0.5,.75));
// show(currentcoordsys, xpen=invisible);

point C=(1,1);
dot("$C$", C, NE, red);

real R=2;
arc a=arc(ellipse(C,R,R/2), 90, 0, fromCenter);
draw(a, linewidth(4mm));

/* View the definition of void markarc(picture,Label,int,real,real,arc,arrowbar,pen,pen,margin,marker) */

/* View the definition of arc *(real, explicit arc) */
draw(0.5*a, 2mm+yellow);

arc ap=a/3;
draw(ap, 1mm+blue);



Étiquettes : , , , ,

## Asymptote using geometry.asy – fig0850

Category: Asymptote,Examples 2D,geometry.asyPh. Ivaldi @ 18 h 02 min

 (Compiled with Asymptote version 2.14svn-r5318)

import geometry;
size(8cm,0);

// currentcoordsys=cartesiansystem((1,2),i=(1,0.5),j=(-0.5,.75));
// show(currentcoordsys, xpen=invisible);

point C=(1,1);
dot("$C$", C, dir(30), red);

arc a=arc(ellipse(C,2,1,30), -45, 45);
draw(a, linewidth(4mm));
dot("$F_1$", a.el.F1, dir(210), red);

/* View the definition of void markarc(picture,Label,int,real,real,arc,arrowbar,pen,pen,margin,marker) */

/* View the definition of arc *(real, explicit arc) */
draw(0.5*a, 2mm+yellow);

arc ap=a/3;
draw(ap, 1mm+blue);



Étiquettes : , , , ,

## Asymptote using geometry.asy – fig1050

Category: Asymptote,Examples 2D,geometry.asyPh. Ivaldi @ 14 h 02 min

 (Compiled with Asymptote version 2.14svn-r5318)

import geometry;
size(8cm,0);

// currentcoordsys=cartesiansystem((1,2),i=(1,0.5),j=(-0.5,.75));
// show(currentcoordsys, xpen=invisible);

point A=(0.25,0.25);
point B=A+(1,0.25);
dot("$A$",A,S,red);
dot("$B$",B,N,red);

segment s=segment(A,B);
line bis=bisector(s);

draw(s,StickIntervalMarker(2,2));
draw(bis);

/* View the definition of path compassmark(pair,pair,real,real) */
draw(compassmark(A, point(bis,0.75), position=0.25,angle=25), grey);
draw(compassmark(B, point(bis,0.75), position=0.75,angle=25), grey);

/* View the definition of point point(line,real) */
draw(compassmark(A, point(bis,0.25), position=0.5,angle=15), grey);
draw(compassmark(B, point(bis,0.25), position=0.5,angle=15), grey);



Étiquettes : , , , , ,

## Asymptote using geometry.asy – fig1090

Category: Asymptote,Examples 2D,geometry.asyPh. Ivaldi @ 18 h 02 min

 (Compiled with Asymptote version 2.14svn-r5318)

import geometry;

size(10cm);

// currentcoordsys=cartesiansystem((2,1),i=(1,0.5),j=(-0.25,.75));
// show(currentcoordsys);

/* View the definition of triangle triangleAbc(real,real,real,real,point) */
triangle t=triangleAbc(60,3,5,angle=90);
show(Lb="3", Lc="5",t);
markangle("$60^\circ$",t.B,t.A,t.C);



Étiquettes : , ,

## Asymptote using geometry.asy – fig1100

Category: Asymptote,Examples 2D,geometry.asyPh. Ivaldi @ 19 h 02 min

 (Compiled with Asymptote version 2.14svn-r5318)

import geometry;
size(10cm,0);

// currentcoordsys=cartesiansystem((2,1),i=(1,0.5),j=(-0.25,0.75));
// show(currentcoordsys);

triangle t=triangle((-1,0), (2,0), (0,2));

drawline(t, linewidth(bp));
/* View the definition of void label(picture,Label,Label,Label,triangle,real,real,pen,filltype) */
label(t, alignFactor=4);

/* View the definition of triangle anticomplementary(triangle) */
triangle at=anticomplementary(t);
draw(at, bp+0.8green);
label("$A'$", "$B'$", "$C'$", at, blue);

draw(segment(at.AB), bp+0.8green, StickIntervalMarker(2,1));
draw(segment(at.BC), bp+0.8green, StickIntervalMarker(2,2));
draw(segment(at.CA), bp+0.8green, CrossIntervalMarker(2,3));



Étiquettes : , , , ,

## Asymptote using geometry.asy – fig1120

Category: Asymptote,Examples 2D,geometry.asyPh. Ivaldi @ 21 h 02 min

 (Compiled with Asymptote version 2.14svn-r5318)

import geometry;
size(10cm,0);

// currentcoordsys=cartesiansystem((2,1),i=(1,0.5),j=(-0.25,0.75));
// show(currentcoordsys);

triangle t=triangle((-1,0), (2,0), (0,2));

drawline(t, linewidth(bp));
label(t,alignFactor=2, alignAngle=90);

/* View the definition of triangle symmedial(triangle) */
triangle st=symmedial(t);
draw(st, bp+0.8green);
label("$A'$", "$B'$", "$C'$", st, alignAngle=45, 0.8green);

/* View the definition of line median(vertex) */
line mA=median(t.VA);
draw(mA, blue);
dot("$M_A$",midpoint(t.BC), 1.5E, blue);
draw(segment(t.BC), bp+blue, StickIntervalMarker(2,2,blue));

/* View the definition of line bisector(vertex,real) */
line bA=bisector(t.VA);
draw(bA, grey);
/* View the definition of point bisectorpoint(side) */
dot("$B_A$", bisectorpoint(t.BC));

/* View the definition of line symmedian(vertex) */
line sA=symmedian(t.VA);
draw(sA, 0.8*green);

draw(symmedian(t.VB), 0.8*green);
draw(symmedian(t.VC), 0.8*green);

/* View the definition of point symmedian(triangle) */
point sP=symmedian(t);
dot(sP);



Étiquettes : , , , , ,

## Asymptote using geometry.asy – fig1130

Category: Asymptote,Examples 2D,geometry.asyPh. Ivaldi @ 22 h 02 min

 (Compiled with Asymptote version 2.14svn-r5318)

import geometry;
size(8cm,0);

// currentcoordsys=cartesiansystem((2,1),i=(1,0.5),j=(-0.25,0.75));
// show(currentcoordsys);

triangle t=rotate(-20)*triangle((-1,0), (2,0), (0,2));
drawline(t, linewidth(bp));
label(t,alignFactor=4);

line bab=bisector(t.AB);
draw(bab, blue);
perpendicularmark(t.AB,bab,quarter=4);

line bac=bisector(t.AC);
draw(bac, blue);
perpendicularmark(t.AC,bac,quarter=4);

line bbc=bisector(t.BC);
draw(bbc, blue);
perpendicularmark(t.BC,bbc,quarter=4);



Étiquettes : , , , , ,

## Asymptote using geometry.asy – fig1140

Category: Asymptote,Examples 2D,geometry.asyPh. Ivaldi @ 23 h 02 min

 (Compiled with Asymptote version 2.14svn-r5318)

import geometry;
size(8cm,0);

// currentcoordsys=cartesiansystem((2,1),i=(1,0.5),j=(-0.25,0.75));
// show(currentcoordsys);

triangle t=rotate(-20)*triangle((-1,0), (2,0), (0,2));
drawline(t, linewidth(bp));
label(t, alignAngle=90, alignFactor=2);

/* View the definition of point incenter(triangle) */
point incenter=incenter(t);

line ba=bisector(t.VA);
draw(ba, blue);
markangle((line) t.AB, (line) t.AC,StickIntervalMarker(i=2,n=1));

line bb=bisector(t.VB);
draw(bb, blue);
markangle((line) t.BC, (line) t.BA, radius=2cm, StickIntervalMarker(i=2,n=2));

line bc=bisector(t.VC);
draw(bc, blue);
markangle((line) t.CA, (line) t.CB, radius=1.5cm, StickIntervalMarker(i=2,n=3));



Étiquettes : , , , ,

## Asymptote using trembling.asy – fig0090

Category: Asymptote,Examples 2D,trembling.asyPh. Ivaldi @ 10 h 24 min

 (Compiled with Asymptote version 1.87svn-r4652)

/*From Mathematex*/
unitsize(1cm);
import trembling;
import base_pi; // for rotatedLabel.

startTrembling();

point pA = (0,0);
point pB = (0,4);
point pC = pB+6*(rotate(35)*unit(pA-pB));
point pD = pC+4*(rotate(-112)*unit(pB-pC));
point pE = pD+4*(rotate(-78)*unit(pC-pD));
point pFi = rotate(35,pE)*pD;

dot(Label("$A$",align=SE),pA);
dot(Label("$B$",align=NW),pB);
dot(Label("$C$",align=SW),pC);
dot(Label("$D$",align=SE),pD);
dot(Label("$E$",align=NW),pE);

line l1 = line(pA,false,pA-(1,0));
line l2 = line(pE,false,pFi);

draw(l1);
draw(l2);
draw(pA--pB, StickIntervalMarker(1,2,size=6,angle=-45,red,true));
draw(rotatedLabel("$6 \; cm$"), pB--pC, N);
draw(rotatedLabel("$4 \; cm$"), pC--pD, S,
StickIntervalMarker(1,2,size=6,angle=-45,red));
draw(pD--pE,
StickIntervalMarker(1,2,size=6,angle=-45,red));

markrightangle(pA-(1,0),pA,pB,blue);
markangle(Label("$35^\circ$"),pA,pB,pC,radius=12mm,blue,StickIntervalMarker(i=1,n=1,size=4,blue));
markangle(Label("$112^\circ$"),pB,pC,pD,radius=7mm,blue);
markangle(Label("$78^\circ$"),pC,pD,pE,radius=5mm,blue);

shipout(bbox(xmargin=1mm,invisible));



Étiquettes : ,

## Asymptote using trembling.asy – fig0100

Category: Asymptote,Examples 2D,trembling.asyPh. Ivaldi @ 11 h 24 min

 Note that the makers are also deformed... (Compiled with Asymptote version 1.87svn-r4652)

import trembling;
size(12cm);
startTrembling();

currentcoordsys=cartesiansystem((2,1),i=(1,0.5),j=(-0.25,1));
show(currentcoordsys);

point A=(1,1);
line l1=line(45,A);
dot("$A$",A);
draw("$(l_1)$",l1);

point B=(3,1);
line l2=line(-60,B);
dot("$B$",B);
draw("$(l_2)$",l2);

markangle(2,l2,l1,0.8*green,StickIntervalMarker(i=1,n=2));

l2,l1,0.8*blue);

markangle(reverse(l2),reverse(l1),Arrow,StickIntervalMarker(i=1,n=2));

markangle((string) sharpdegrees(l2,l1),
reverse(l2),l1,Arrow,red);



Étiquettes : , ,

## Asymptote using solids.asy – fig0090

Category: Asymptote,Examples 3D,solids.asyPh. Ivaldi @ 10 h 56 min

 (Compiled with Asymptote version 2.14svn-r5318)

size(8cm,0);
import solids;
import graph3;

//Draw 3D right angle (MA,MB)
void drawrightangle(picture pic=currentpicture,
triple M, triple A, triple B,
pen p=currentpen,
pen fillpen=nullpen,
projection P=currentprojection)
{
p=linejoin(0)+linecap(0)+p;
transform3 T=shift(-M);
OC=OA+OB;
path3 tp=OA--OC--OB;
picture tpic;
draw(tpic, tp, p=p);
if (fillpen!=nullpen) draw(tpic, surface(O--tp--cycle), fillpen);
}

currentprojection=orthographic(10,15,3);

real r=10, h=6; // r=sphere radius; h=altitude section
triple Op=(0,0,h);

limits((0,0,0),1.1*(r,r,r));
axes3("x","y","z");

real ch=180*acos(h/r)/pi;
path3 arcD=Arc(O,r,180,0,ch,0,Y,50);

revolution sphereD=revolution(O,arcD,Z);
draw(surface(sphereD), opacity(0.5)+lightblue);
draw(shift(0,0,h)*scale3(rs)*surface(unitcircle3),opacity(0.5));

path3 arcU=Arc(O,r,ch,0,0,0,Y,10);
revolution sphereU=revolution(O,arcU,Z);
draw(surface(sphereU), opacity(0.33)+lightgrey);

// right triangle OO'A
triple A=rotate(100,Z)*(rs,0,h);
dot("$O$",O,NW);
dot("$O'$",Op,W);
dot("$A$",A,N);
draw(A--O--Op--A);
drawrightangle(Op,O,A);

if(!is3D())
shipout(format="pdf", bbox(Fill(paleyellow)));



Étiquettes : , , , , ,

## Asymptote using solids.asy – fig0120

Category: Asymptote,Examples 3D,solids.asyPh. Ivaldi @ 13 h 56 min

 (Compiled with Asymptote version 2.14svn-r5318)

import solids;

size(10cm,0);
currentprojection=orthographic(-50,100,40);

//Draw right angle (MA,MB) in 3D
void drawrightangle(picture pic=currentpicture,
triple M, triple A, triple B,
pen p=currentpen,
pen fillpen=nullpen,
projection P=currentprojection)
{
p=linejoin(0)+linecap(0)+p;
transform3 T=shift(-M);
OC=OA+OB;
path3 _p=OA--OC--OB;
picture pic_;
draw(pic_, _p, p=p);
if (fillpen!=nullpen) draw(pic_, surface(O--_p--cycle), fillpen);
}

// *...............Construction starts here................*

real r=1, h=.75;
real gle=60;
real gleA=20;
transform3 tR=rotate(gle,Z);
transform3 tT=shift((0,0,-h));

triple H=(0,0,h),//the label is O in the picture.
A=rotate(gleA,Z)*(0,r,h),
F=tR*A,
B=tR*F,
D=tT*A,
C=tT*B,
Ei=intersectionpoint(H--F,A--B);

revolution r=cylinder(O,r,h,Z);
// draw(surface(r));
draw(r);

draw(O--H, dashed);
draw(O--D--C--cycle^^O--H^^B--C, dashed);

drawrightangle(Ei,H,B,fillpen=black);

dot(Label("$O'$",align=invert(NE+E,O)), O);
// layer();
draw(surface(A--B--C--D--cycle),lightgrey+opacity(.5));

dot(Label("$A$",align=NW), A);
dot(Label("$B$",align=N),B);
dot(Label("$C$",align=S), C);
dot(Label("$D$",align=NW), D);
dot(Label("$E$",align=S), Ei);
dot(Label("$F$",align=S), F);
dot(Label("$O$",align=N), H);

draw(H--B--F--A--cycle^^H--F^^A--B^^A--D);



Étiquettes : , , , ,

## Unofficial package graph_pi.asy – fig0210

Category: Asymptote,graph_pi.asy,Unofficial packagesPh. Ivaldi @ 1 h 50 min

 (Compiled with Asymptote version 2.14svn-r5318)

import graph_pi;

unitsize(x=3cm,y=3cm);
// All marks will have this size. Default=sqrt(2)*dotsize(currentpen);
graphmarksize=4mm;

real f(real x){return sin(x);};
path Cf=graph(f, .5, 2);
transform T=shift((0,-.5));
// ---------------------------------
// * definition of ArcMarkerExtrem *
// marker ArcMarkerExtrem(real radius=graphmarksize(), real angle=180,
//                        bool begin=true, bool end=true,
//                        pen p=currentpen, bool put=Above)

draw(Cf, ArcMarkerExtrem());
draw(T*Cf, red, ArcMarkerExtrem(angle=270, begin=false));

// ----------------------------------
// * Definition of Hookmarkerextrem *
// marker HookMarkerExtrem(real height=graphmarksize(), real width=height/2,
//                         bool begin=true, bool end=true,
//                         pen p=currentpen, bool put=Above)

draw(T^3*Cf,HookMarkerExtrem);//Without brackets values returns to default
draw(T^4*Cf, green, HookMarkerExtrem(height=2*graphmarksize, width=-graphmarksize*2,green));

// ------------------------------------
// * Definition of CircleMarkerExtrem *
// marker CircleMarkerExtrem(real radius=graphmarksize(), real angle=90,
//                           bool begin=true, bool end=true,
//                           pen p=currentpen, filltype filltype=NoFill,
//                           bool put=Above)

draw(T^5*Cf, green, CircleMarkerExtrem(green));



Étiquettes : ,

## Official Asymptote example – HermiteSpline

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 16 h 57 min

 (Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */

import graph;

size(140mm,70mm,IgnoreAspect);
scale(false);
real[] x={1,3,4,5,6};
real[] y={1,5,2,0,4};

marker mark=marker(scale(1mm)*cross(6,false,r=0.35),red,Fill);

draw(graph(x,y,Hermite),"Hermite Spline",mark);
xaxis("$x$",Bottom,LeftTicks(x));
yaxis("$y$",Left,LeftTicks);
attach(legend(),point(NW),40S+30E,UnFill);



Étiquettes : , , , ,

## Official Asymptote example – Pythagoras

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 21 h 57 min

 (Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */

size(0,150);
import geometry;

real a=3;
real b=4;
real c=hypot(a,b);

pair z1=(0,b);
pair z2=(a,0);
pair z3=(a+b,0);
perpendicular(z1,NE,z1--z2,blue);
perpendicular(z3,NW,blue);
draw(square((0,0),z3));
draw(square(z1,z2));

real d=0.3;
pair v=unit(z2-z1);
draw(baseline("$a$"),-d*I--z2-d*I,red,Bars,Arrows,PenMargins);
draw(baseline("$b$"),z2-d*I--z3-d*I,red,Arrows,Bars,PenMargins);
draw("$c$",z3+z2*I-d*v--z2-d*v,red,Arrows,PenMargins);
draw("$a$",z3+d--z3+z2*I+d,red,Arrows,Bars,PenMargins);
draw("$b$",z3+z2*I+d--z3+z3*I+d,red,Arrows,Bars,PenMargins);



Étiquettes : , , , , ,

## Official Asymptote example – cosaddition

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 2 h 57 min

 (Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */

size(0,200);
import geometry;

real A=130;
real B=40;

pair O=(0,0);
pair R=(1,0);
pair P=dir(A);
pair Q=dir(B);

draw(circle(O,1.0));
draw(Q--O--P);
draw(P--Q,red);
draw(O--Q--R--cycle);

draw("$A$",arc(R,O,P,0.3),blue,Arrow,PenMargin);
draw("$B$",arc(R,O,Q,0.6),blue,Arrow,PenMargin);
pair S=(Cos(B),0);
draw(Q--S,blue);
perpendicular(S,NE,blue);

dot(O);
dot("$R=(1,0)$",R);
dot("$P=(\cos A,\sin A)$",P,dir(O--P)+W);
dot("$Q=(\cos B,\sin B)$",Q,dir(O--Q));



Étiquettes : , , ,

## Official Asymptote example – errorbars

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 22 h 57 min

 (Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */

import graph;

picture pic;
real xsize=200, ysize=140;
size(pic,xsize,ysize,IgnoreAspect);

pair[] f={(5,5),(50,20),(90,90)};
pair[] df={(0,0),(5,7),(0,5)};

errorbars(pic,f,df,red);
draw(pic,graph(pic,f),"legend",
marker(scale(0.8mm)*unitcircle,red,FillDraw(blue),above=false));

scale(pic,true);

xaxis(pic,"$x$",BottomTop,LeftTicks);
yaxis(pic,"$y$",LeftRight,RightTicks);

picture pic2;
size(pic2,xsize,ysize,IgnoreAspect);

frame mark;
filldraw(mark,scale(0.8mm)*polygon(6),green,green);
draw(mark,scale(0.8mm)*cross(6),blue);

draw(pic2,graph(pic2,f),marker(mark,markuniform(5)));

scale(pic2,true);

xaxis(pic2,"$x$",BottomTop,LeftTicks);
yaxis(pic2,"$y$",LeftRight,RightTicks);

yequals(pic2,55.0,red+Dotted);
xequals(pic2,70.0,red+Dotted);

// Fit pic to W of origin:

// Fit pic2 to E of (5mm,0):



Étiquettes : , , , ,

## Official Asymptote example – graphmarkers

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 19 h 57 min

 (Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */

import graph;

size(200,100,IgnoreAspect);

markroutine marks() {
return new void(picture pic=currentpicture, frame f, path g) {
path p=scale(1mm)*unitcircle;
for(int i=0; i <= length(g); ++i) {
pair z=point(g,i);
frame f;
if(i % 4 == 0) {
fill(f,p);
} else {
if(z.y > 50) {
pic.add(new void(frame F, transform t) {
path q=shift(t*z)*p;
unfill(F,q);
draw(F,q);
});
} else {
draw(f,p);
}
}
}
};
}

pair[] f={(5,5),(40,20),(55,51),(90,30)};

draw(graph(f),marker(marks()));

scale(true);

xaxis("$x$",BottomTop,LeftTicks);
yaxis("$y$",LeftRight,RightTicks);



Étiquettes : ,

## Official Asymptote example – leastsquares

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 22 h 57 min

 (Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */

size(400,200,IgnoreAspect);

import graph;
import stats;

file fin=input("leastsquares.dat").line();

real[][] a=fin.dimension(0,0);
a=transpose(a);

real[] t=a[0], rho=a[1];

// Read in parameters from the keyboard:
//real first=getreal("first");
//real step=getreal("step");
//real last=getreal("last");

real first=100;
real step=50;
real last=700;

// Remove negative or zero values of rho:
t=rho > 0 ? t : null;
rho=rho > 0 ? rho : null;

scale(Log(true),Linear(true));

int n=step > 0 ? ceil((last-first)/step) : 0;

real[] T,xi,dxi;

for(int i=0; i <= n; ++i) {
real first=first+i*step;
real[] logrho=(t >= first & t <= last) ? log(rho) : null;
real[] logt=(t >= first & t <= last) ? -log(t) : null;

if(logt.length < 2) break;

// Fit to the line logt=L.m*logrho+L.b:
linefit L=leastsquares(logt,logrho);

T.push(first);
xi.push(L.m);
dxi.push(L.dm);
}

draw(graph(T,xi),blue);
errorbars(T,xi,dxi,red);

crop();

ylimits(0);

xaxis("$T$",BottomTop,LeftTicks);
yaxis("$\xi$",LeftRight,RightTicks);



Étiquettes : , , ,

## Official Asymptote example – markers1

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 19 h 57 min

 (Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */

size(12cm,0);
import markers;

pair A=(0,0), B=(1,0), C=(2,0), D=(3,0);
path p=A--B--C--D;
transform T=shift(-4,-1);
transform t=shift(4,0);

//line 1 **********
draw(p,marker(markinterval(3,dotframe,true)));
label("$1$",point(p,0),3W);

//line 2 **********
p=t*p;
draw(p,marker(stickframe,markuniform(4)));
label("$2$",point(p,0),3W);

//line 3 **********
p=T*p;
draw(p,marker(stickframe(red),markinterval(3,dotframe(blue),true)));
label("$3$",point(p,0),3W);

//line 4 **********
p=t*p;
draw(p,StickIntervalMarker(3,2,blue,dotframe(red)));
label("$4$",point(p,0),3W);

//line 5 **********
p=T*p;
pen pn=linewidth(4bp);
draw(p,pn,StickIntervalMarker(3,3,angle=25,pn,dotframe(red+pn)));
label("$5$",point(p,0),3W);

//line 6 **********
p=t*p;
draw(p,StickIntervalMarker(3,5,angle=25,size=4mm,space=2mm,offset=I*2mm,
scale(2)*dotframe(red)));
label("$6$",point(p,0),3W);

//line 7 **********
p=T*p;
draw(p,StickIntervalMarker(n=3,angle=45,size=10mm,space=3mm,dotframe));
label("$7$",point(p,0),3W);

//line 8 **********
p=t*p;
draw(p,CircleBarIntervalMarker(n=2,dotframe));
label("$8$",point(p,0),3W);

//line 9 **********
p=T*p;
FillDraw(.8red),
dotframe));
label("$9$",point(p,0),3W);

//line 10 **********
p=t*p;
FillDraw(.8red),circleabove=true,dotframe));
label("$10$",point(p,0),3W);

//line 11 **********
p=T*p;
FillDraw(.8red),circleabove=true,dotframe,
above=false));
label("$11$",point(p,0),3W);

//line 12 **********
p=t*p;
draw(p,TildeIntervalMarker(i=3,dotframe));
label("$12$",point(p,0),3W);

//line 13 **********
p=T*p;
draw(p,TildeIntervalMarker(i=3,n=2,angle=-20,dotframe));
label("$13$",point(p,0),3W);

//line 14 **********
p=t*p;
draw(p,CrossIntervalMarker(3,3,dotframe));
label("$14$",point(p,0),3W);

//line 15 **********
p=shift(.25S)*T*p;
path cle=shift(relpoint(p,.5))*scale(abs(A-D)/4)*unitcircle;
draw(cle,StickIntervalMarker(5,3,dotframe(6bp+red)));
label("$15$",point(p,0),3W);

//line 16 **********
cle=t*cle;
p=t*p;
frame a;
label(a,"$a$",(0,-2labelmargin()));
draw(cle,marker(dotframe(6bp+red),markinterval(5,a,true)));
label("$16$",point(p,0),3W);

// line 17 **********
p=T*shift(relpoint(p,.5)+.65S)*scale(.5)*shift(-relpoint(p,.5))*rotate(45,relpoint(p,.5))*p;
draw(p,TildeIntervalMarker(size=5mm,rotated=false,dotframe));
label("$17$",point(p,0),3W);



Étiquettes :

## Official Asymptote example – markers2

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 20 h 57 min

 (Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */

size(10cm,0);
import markers;
import geometry;
import math;

pair A=0, B=(1,0), C=(0.7,1), D=(-0.5,0), F=rotate(-90)*(C-B)/2+B;

draw(A--B);
draw(A--C);
pen p=linewidth(1mm);
draw(B--C,p);
draw(A--D);
draw(B--F,p);
label("$A$",A,SW);
label("$B$",B,S);
label("$C$",C,N);
dot(Label("$D$",D,S));
dot(Label("$F$",F,N+NW));

markangle(A,C,B);

markangle(scale(1.5)*"$\theta$",radius=40,C,B,A,ArcArrow(2mm),1mm+red);
markangle(scale(1.5)*"$-\theta$",radius=-70,A,B,C,ArcArrow,green);

markangle(Label("$\gamma$",Relative(0.25)),n=2,radius=-30,A,C,B,p=0.7blue+2);

markangle(n=3,B,A,C,marker(markinterval(stickframe(n=2),true)));

pen RedPen=0.7red+1bp;
markangle(C,A,D,RedPen,marker(markinterval(2,stickframe(3,4mm,RedPen),true)));
drawline(A,A+dir(A--D,A--C),dotted);

perpendicular(B,NE,F-B,size=10mm,1mm+red,
TrueMargin(linewidth(p)/2,linewidth(p)/2),Fill(yellow));



Étiquettes : ,

## Official Asymptote example – markregular

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 21 h 57 min

 (Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */

import graph;

size(10cm,0);

real xmin=-4,xmax=4;
real ymin=-2,ymax=10;

real f(real x) {return x^2;}

marker cross=marker(scale(4)*rotate(45)*cross(4),
markuniform(new pair(real t) {return Scale((t,f(t)));},
xmin,xmax,round(2*(xmax-xmin))),1bp+red);

draw(graph(f,xmin,xmax,n=400),linewidth(1bp),cross);

ylimits(-2.5,10,Crop);

xaxis(Label("$x$",position=EndPoint, align=NE),xmin=xmin,xmax=xmax,
Ticks(scale(.7)*Label(align=E),NoZero,begin=false,beginlabel=false,
end=false,endlabel=false,Step=1,step=.25,
Size=1mm, size=.5mm,pTick=black,ptick=gray),Arrow);

yaxis(Label("$y$",position=EndPoint, align=NE),ymin=ymin,ymax=ymax,
Ticks(scale(.7)*Label(),NoZero,begin=false,beginlabel=false,
end=false,endlabel=false,Step=1,step=.25,Size=1mm,size=.5mm,
pTick=black,ptick=gray),Arrow);



Étiquettes : , ,

## Official Asymptote example – orthocenter

Category: Asymptote,Official Gallery One-PagerPh. Ivaldi @ 7 h 57 min

 (Compiled with Asymptote version 2.14svn-r5318)
/* This code comes from The Official Asymptote Gallery */

import geometry;
import math;

size(7cm,0);

real theta=degrees(asin(0.5/sqrt(7)));

pair B=(0,sqrt(7));
pair A=B+2sqrt(3)*dir(270-theta);
pair C=A+sqrt(21);
pair O=0;

pair Ap=extension(A,O,B,C);
pair Bp=extension(B,O,C,A);
pair Cp=extension(C,O,A,B);

perpendicular(Ap,NE,Ap--O,blue);
perpendicular(Bp,NE,Bp--C,blue);
perpendicular(Cp,NE,Cp--O,blue);

draw(A--B--C--cycle);

currentpen=black;

draw("1",A--O,-0.25*I*dir(A--O));
draw(O--Ap);
draw("$\sqrt{7}$",B--O,LeftSide);
draw(O--Bp);
draw("4",C--O);
draw(O--Cp);

dot("$O$",O,dir(B--Bp,Cp--C),red);
dot("$A$",A,dir(C--A,B--A),red);
dot("$B$",B,NW,red);
dot("$C$",C,dir(A--C,B--C),red);
dot("$A'$",Ap,dir(A--Ap),red);
dot("$B'$",Bp,dir(B--Bp),red);
dot("$C'$",Cp,dir(C--Cp),red);

label(graphic("piicon","width=2.5cm"),Ap,5ENE,red);



Étiquettes : , ,