## Asymptote using three.asy – fig0070

Category: Asymptote,Examples 3D,three.asyPh. Ivaldi @ 20 h 50 min

 (Compiled with Asymptote version 2.14svn-r5318)

// From the Asymptote forum
import bsp;

typedef path3[] shape;

shape operator *(transform3 T, shape p){
shape os;
for(path3 g:p) os.push(T*g);
return os;
}

path3 path(triple[] T){
path3 P;
for(triple i:T) P=P--i;
return P;
}

void addshapes(face[] F, shape[] shp, pen drawpen=currentpen, pen fillpen=white)
{
for(int i=0; i < shp.length; ++i)
for(int j=0; j < shp[i].length; ++j) {
path3 g=shp[i][j];
picture pic=F.push(g);
filldraw(pic,project(g),fillpen, drawpen);
// filldraw(pic,g,currentlight.intensity(F[F.length-1].point)*fillpen, drawpen);
}
}

shape cylinder(real R=1, real H=1, int n=18){
shape Cyl;
triple[] CTop;
triple[] CBot;
for(int i=0; i <= n; ++i)
CBot.push((R*cos(2pi*i/n), R*sin(2pi*i/n),0));
CTop = CBot+(0,0,H);
for(int i=0; i < n; ++i)
Cyl.push(CBot[i]--CBot[i+1]--CTop[i+1]--CTop[i]--cycle);

path3 P=path(CBot)--cycle;
Cyl.push(P);
Cyl.push(shift(H*Z)*P);

return Cyl;
}

shape rightslab(real x=1, real y=1, real z=1){
shape slab;
slab[0] = (0,0,0)--(1,0,0)--(1,1,0)--(0,1,0)--cycle;
slab[1] = (0,0,0)--(1,0,0)--(1,0,1)--(0,0,1)--cycle;
slab[2] = (1,0,0)--(1,1,0)--(1,1,1)--(1,0,1)--cycle;
slab[3] = (1,1,0)--(0,1,0)--(0,1,1)--(1,1,1)--cycle;
slab[4] = (0,1,0)--(0,0,0)--(0,0,1)--(0,1,1)--cycle;
slab[5] = (0,0,1)--(1,0,1)--(1,1,1)--(0,1,1)--cycle;
return scale(x,y,z)*slab;
}

size(10cm,0);
triple cam=(1600,200,150);
//currentprojection=orthographic(1600,800,400);
currentprojection=perspective(cam); //Far away!
currentlight=rotate(-45,Z)*(cam+(0,0,1000));

real Blen = 180;
real Bwdt = 30;
real Bhgt = 3;
real Clen = 130;
real Cwdt = 50;
real Chgt = 50;
real cylr = 7.5;
real cylh = 37.0 ;

shape slab1 = shift(-Bwdt/2*Y-Bhgt/2*Z+Clen/2*X)*rightslab(Blen,Bwdt,Bhgt);
shape slab2 = shift(-Cwdt/2*Y-Chgt/2*Z-Clen/2*X)*rightslab(Clen,Cwdt,Chgt);
shape cyl1 = shift((Blen+Clen/2-2*cylr)*X-(cylh/2)*Z)*cylinder(R=cylr, H=cylh);

shape[] group1={slab1};
shape[] group2={slab2};
shape[] group3={cyl1};

face[] faces;

shipout(format="pdf", bbox(3mm,white));



Étiquettes : , ,

## Asymptote using three.asy – fig0080

Category: Asymptote,Examples 3D,three.asyPh. Ivaldi @ 21 h 50 min

 (Compiled with Asymptote version 2.14svn-r5318)

import bsp;

typedef path3[] shape;

shape operator *(transform3 T, shape p){
shape os;
for(path3 g:p) os.push(T*g);
return os;
}

path3 path(triple[] T){
path3 P;
for(triple i:T) P=P--i;
return P;
}

void addshapes(face[] F, shape[] shp, pen drawpen=currentpen, pen fillpen=white)
{
for(int i=0; i < shp.length; ++i)
for(int j=0; j < shp[i].length; ++j) {
path3 g=shp[i][j];
picture pic=F.push(g);
if(fillpen != nullpen) filldraw(pic,project(g),fillpen, drawpen);
else draw(pic,project(g),drawpen);
// filldraw(pic,g,currentlight.intensity(F[F.length-1].point)*fillpen, drawpen);
}
}

shape cylinder(real R=1, real H=1, int n=18){
shape Cyl;
triple[] CTop;
triple[] CBot;
for(int i=0; i <= n; ++i)
CBot.push((R*cos(2pi*i/n), R*sin(2pi*i/n),0));
CTop = CBot+(0,0,H);
for(int i=0; i < n; ++i)
Cyl.push(CBot[i]--CBot[i+1]--CTop[i+1]--CTop[i]--cycle);

path3 P=path(CBot)--cycle;
Cyl.push(P);
Cyl.push(shift(H*Z)*P);

return Cyl;
}

size(10cm,0);

currentprojection=orthographic(1,1,1);

shape cyl1 = cylinder(R=1, H=2);

shape[] group={cyl1};

face[] hidden, visible;

shipout(format="pdf");



Étiquettes : , , ,

## Asymptote using three.asy – fig0100

Category: Asymptote,Examples 3D,three.asyPh. Ivaldi @ 23 h 50 min

 (Compiled with Asymptote version 2.14svn-r5318)

size(12cm,0);
import bsp;

currentprojection=orthographic(1,1.5,1);

path3 xy=plane((1,0,0),(0,1,0),(0,0,0));
path3 xz=rotate(90,X)*xy;
path3 yz=rotate(-90,Y)*xy;

face[] f;
filldraw(f.push(xy),project(xy),grey);
filldraw(f.push(xz),project(xz),grey);
filldraw(f.push(yz),project(yz),grey);

draw(Label("$x$",EndPoint), O--(1,0,0), Arrow3);
draw(Label("$y$",EndPoint), O--(0,1,0), Arrow3);
draw(Label("$z$",EndPoint), O--(0,0,1), Arrow3);
dot(O);

path[] ph=texpath("$\displaystyle\int_{-\infty}^{+\infty}e^{-\alpha x^2}\,dx= \sqrt{\frac{\pi}{\alpha}}$");
ph =shift((0.5,0.5))*rotate(-45)*scale(1/abs(min(ph)-max(ph)))*ph;

filldraw(project(path3(ph,XYplane)),0.8*yellow);
filldraw(project(path3(ph,ZXplane)),0.8*yellow);
filldraw(project(path3(ph,YZplane)),0.8*yellow);



Étiquettes : , , , , ,

## Official Asymptote example – colorplanes

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(6cm,0);
import bsp;

real u=2.5;
real v=1;

currentprojection=oblique;

path3 y=plane((2u,0,0),(0,2v,0),(-u,-v,0));
path3 l=rotate(90,Z)*rotate(90,Y)*y;
path3 g=rotate(90,X)*rotate(90,Y)*y;

face[] faces;
pen[] p={red,green,blue,black};
int[] edges={0,0,0,2};
edges);



Étiquettes : ,

## Official Asymptote example – planes

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(6cm,0);
import bsp;

real u=2.5;
real v=1;

currentprojection=oblique;

path3 y=plane((2u,0,0),(0,2v,0),(-u,-v,0));
path3 l=rotate(90,Z)*rotate(90,Y)*y;
path3 g=rotate(90,X)*rotate(90,Y)*y;

face[] faces;
filldraw(faces.push(y),project(y),yellow);
filldraw(faces.push(l),project(l),lightgrey);
filldraw(faces.push(g),project(g),green);