## Official Asymptote example – BezierPatch

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 three;

size(10cm);
currentlight=Viewport;

surface s=surface(patch(new triple[][] {
{(0,0,0),(1,0,0),(1,0,0),(2,0,0)},
{(0,1,0),(1,0,1),(1,0,1),(2,1,0)},
{(0,1,0),(1,0,-1),(1,0,-1),(2,1,0)},
{(0,2,0),(1,2,0),(1,2,0),(2,2,0)}}));

draw(s,yellow);
draw(s.s[0].vequals(0.5),squarecap+2bp+blue,currentlight);
draw(s.s[0].uequals(0.5),squarecap+2bp+red,currentlight);



Étiquettes : , , ,

## Official Asymptote example – BezierSurface

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

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

import three;

string viewpoint="
COO=-684.0787963867188 206.90650939941406 218.13809204101562
C2C=0.8244762420654297 -0.563306450843811 0.0540805421769619
ROO=1009.7407942621448
ROLL=17.39344555165265
";

// viewpoint=getstring("viewpoint",viewpoint);
currentprojection=perspective(viewpoint);

triple[][][] P={
{
{(-1.6,0,1.875),(-2.3,0,1.875),(-2.7,0,1.875),(-2.7,0,1.65),},
{(-1.6,-0.3,1.875),(-2.3,-0.3,1.875),(-2.7,-0.3,1.875),(-2.7,-0.3,1.65),},
{(-1.5,-0.3,2.1),(-2.5,-0.3,2.1),(-3,-0.3,2.1),(-3,-0.3,1.65),},
{(-1.5,0,2.1),(-2.5,0,2.1),(-3,0,2.1),(-3,0,1.65),}
},{
{(-2.7,0,1.65),(-2.7,0,1.425),(-2.5,0,0.975),(-2,0,0.75),},
{(-2.7,-0.3,1.65),(-2.7,-0.3,1.425),(-2.5,-0.3,0.975),(-2,-0.3,0.75),},
{(-3,-0.3,1.65),(-3,-0.3,1.2),(-2.65,-0.3,0.7275),(-1.9,-0.3,0.45),},
{(-3,0,1.65),(-3,0,1.2),(-2.65,0,0.7275),(-1.9,0,0.45),}
},{
{(-2.7,0,1.65),(-2.7,0,1.875),(-2.3,0,1.875),(-1.6,0,1.875),},
{(-2.7,0.3,1.65),(-2.7,0.3,1.875),(-2.3,0.3,1.875),(-1.6,0.3,1.875),},
{(-3,0.3,1.65),(-3,0.3,2.1),(-2.5,0.3,2.1),(-1.5,0.3,2.1),},
{(-3,0,1.65),(-3,0,2.1),(-2.5,0,2.1),(-1.5,0,2.1),}
},{
{(-2,0,0.75),(-2.5,0,0.975),(-2.7,0,1.425),(-2.7,0,1.65),},
{(-2,0.3,0.75),(-2.5,0.3,0.975),(-2.7,0.3,1.425),(-2.7,0.3,1.65),},
{(-1.9,0.3,0.45),(-2.65,0.3,0.7275),(-3,0.3,1.2),(-3,0.3,1.65),},
{(-1.9,0,0.45),(-2.65,0,0.7275),(-3,0,1.2),(-3,0,1.65),}
}
};

picture pic;
size(pic,15cm);
size3(pic,10cm);
draw(pic,surface(P),blue);



Étiquettes : , , ,

## Official Asymptote example – Bode

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

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

import graph;
texpreamble("\def\Arg{\mathop {\rm Arg}\nolimits}");

size(10cm,5cm,IgnoreAspect);

real ampl(real x) {return 2.5/(1+x^2);}
real phas(real x) {return -atan(x)/pi;}

scale(Log,Log);
draw(graph(ampl,0.01,10));
ylimits(0.001,100);

xaxis("$\omega\tau_0$",BottomTop,LeftTicks);
yaxis("$|G(\omega\tau_0)|$",Left,RightTicks);

picture q=secondaryY(new void(picture pic) {
scale(pic,Log,Linear);
draw(pic,graph(pic,phas,0.01,10),red);
ylimits(pic,-1.0,1.5);
yaxis(pic,"$\Arg G/\pi$",Right,red,
LeftTicks("$% #.1f$",
begin=false,end=false));
yequals(pic,1,Dotted);
});
label(q,"(1,0)",Scale(q,(1,0)),red);



Étiquettes : , , ,

## Official Asymptote example – CAD1

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

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

// Freehand line

// Standard measurement lines
cad.MeasureParallel(L="$\sqrt{2}$",
pFrom=(0,1)*cm,
pTo=(1,0)*cm,
dblDistance=-15mm);

// Label inside,shifted to the right; arrows outside
pFrom=(2,1)*cm,
pTo=(3,1)*cm,
dblDistance=5mm,
dblLeft=5mm,
dblRelPosition=0.75);

// Label and arrows outside
pFrom=(5,1)*cm,
pTo=(5.5,1)*cm,
dblDistance=5mm,
dblLeft=10mm,
dblRelPosition=-1);

// Small bounds,asymmetric measurement line
pFrom=(7,1)*cm,
pTo=(7.5,1)*cm,
dblDistance=5mm,
dblRight=10mm,
dblRelPosition=2,
bSmallBound=true);



Étiquettes :

## Official Asymptote example – CDlabel

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

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

size(11.7cm,11.7cm);
asy(nativeformat(),"logo");
fill(unitcircle^^(scale(2/11.7)*unitcircle),
evenodd+rgb(124/255,205/255,124/255));
label(scale(1.1)*minipage(
"\centering\scriptsize \textbf{\LARGE {\tt Asymptote}\\
\smallskip
\small The Vector Graphics Language}\\
\smallskip
\textsc{Andy Hammerlindl, John Bowman, and Tom Prince}
http://asymptote.sourceforge.net\\
",8cm),(0,0.6));
label(graphic("logo."+nativeformat(),"height=7cm"),(0,-0.22));
clip(unitcircle^^(scale(2/11.7)*unitcircle),evenodd);



Étiquettes : , , ,

## Official Asymptote example – Coons

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

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

size(200);

pen[] p={red,green,blue,magenta};
path g=(0,0){dir(45)}..(1,0)..(1,1)..(0,1)..cycle;
dot(g);



Étiquettes : , ,

## Official Asymptote example – GaussianSurface

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

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

import graph3;

size(200,0);

currentprojection=perspective(10,8,4);

real f(pair z) {return 0.5+exp(-abs(z)^2);}

draw((-1,-1,0)--(1,-1,0)--(1,1,0)--(-1,1,0)--cycle);

draw(arc(0.12Z,0.2,90,60,90,25),ArcArrow3);

surface s=surface(f,(-1,-1),(1,1),nx=5,Spline);

xaxis3(Label("$x$"),red,Arrow3);
yaxis3(Label("$y$"),red,Arrow3);
zaxis3(XYZero(extend=true),red,Arrow3);

draw(s,lightgray,meshpen=black+thick(),nolight,render(merge=true));

label("$O$",O,-Z+Y,red);



Étiquettes : , ,

## Official Asymptote example – Gouraud

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

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

size(200);

pen[] p={red,green,blue,magenta};
pair[] z={(-1,0),(0,0),(0,1),(1,0)};
int[] edges={0,0,0,1};

draw(z[0]--z[1]--z[2]--cycle);
draw(z[1]--z[3]--z[2],dashed);

dot(Label,z[0],W);
dot(Label,z[1],S);
dot(Label,z[2],N);
dot(Label,z[3],E);

label("0",z[0]--z[1],S,red);
label("1",z[1]--z[2],E,red);
label("2",z[2]--z[0],NW,red);



Étiquettes : ,

## Official Asymptote example – Gouraudcontour

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

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

import graph;
import palette;
import contour;

size(200);

int n=100;

real[] x=new real[n];
real[] y=new real[n];
real[] f=new real[n];

real F(real a, real b) {return a^2+b^2;}

real r() {return 1.1*(rand()/randMax*2-1);}

for(int i=0; i < n; ++i) {
x[i]=r();
y[i]=r();
f[i]=F(x[i],y[i]);
}

pen Tickpen=black;
pen tickpen=gray+0.5*linewidth(currentpen);
pen[] Palette=BWRainbow();

bounds range=image(x,y,f,Range(0,2),Palette);
draw(contour(pairs(x,y),f,new real[]{0.25,0.5,1},operator ..));

palette("$f(x,y)$",range,point(NW)+(0,0.5),point(NE)+(0,0.8),Top,Palette,
PaletteTicks(Tickpen,tickpen));



É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 : , , , ,