|
|
|
(Compiled with Asymptote version 1.87svn-r4652)
|
|
import tube;
import graph3;
size(10cm,0);
currentprojection=perspective(4,3,4);
triple f(real t){
return t*Z+(cos(2pi*t),sin(2pi*t),0)/sqrt(1+0.5*t^2);
}
path3 p=graph(f,0,2.7,operator ..);
draw(tube(p,scale(0.2)*polygon(5)), purple);
Mots-clefs : Graph (3D), tube
|
|
|
(Compiled with Asymptote version 1.87svn-r4652)
|
|
import tube;
import graph3;
size(10cm,0);
currentprojection=perspective(4,3,4);
real x(real t) {return (1/sqrt(1+0.5*t^2))*cos(2pi*t);}
real y(real t) {return (1/sqrt(1+0.5*t^2))*sin(2pi*t);}
real z(real t) {return t;}
path3 p=graph(x,y,z,0,2.7,operator ..);
path section=scale(0.2)*polygon(5);
// tube.asy defines a "colored path".
// The value of coloredtype may be coloredSegments or coloredNodes.
// Here the path scale(0.2)*polygon(5) has fixed colored SEGMENTS.
coloredpath cp=coloredpath(section,
// The array of pens become automatically cyclic.
new pen[]{0.8*red, 0.8*blue, 0.8*yellow, 0.8*purple, black},
colortype=coloredSegments);
// Draw the tube, each SEGMENT of the section is colored.
draw(tube(p,cp));
Mots-clefs : Graph (3D), Shading (3D), tube
|
|
|
(Compiled with Asymptote version 1.87svn-r4652)
|
|
import tube;
import graph3;
size(10cm,0);
currentprojection=perspective(4,3,4);
real x(real t) {return (1/sqrt(1+0.5*t^2))*cos(2pi*t);}
real y(real t) {return (1/sqrt(1+0.5*t^2))*sin(2pi*t);}
real z(real t) {return t;}
path3 p=graph(x,y,z,0,2.7,operator ..);
path section=scale(0.2)*polygon(5);
// Here the path scale(0.2)*polygon(5) has colored NODES.
coloredpath cp=coloredpath(section,
new pen[]{0.8*red, 0.8*blue, 0.8*yellow, 0.8*purple, black},
colortype=coloredNodes);
// Draw the tube, each NODE of the section is colored.
draw(tube(p,cp));
Mots-clefs : Graph (3D), Shading (3D), tube
|
|
|
(Compiled with Asymptote version 1.87svn-r4652)
|
|
import tube;
import graph3;
size(10cm,0);
currentprojection=perspective(4,3,4);
real x(real t) {return (1/sqrt(1+0.5*t^2))*cos(2pi*t);}
real y(real t) {return (1/sqrt(1+0.5*t^2))*sin(2pi*t);}
real z(real t) {return t;}
path3 p=graph(x,y,z,0,2.7,operator ..);
path section=scale(0.2)*polygon(5);
// Define a pen wich depends of a real t. t represent the "reltime" of the path3 p.
pen pen(real t){
return interp(red,blue,1-2*abs(t-0.5));
}
// Here the section has colored segments (by default) depending to reltime.
draw(tube(p,coloredpath(section,pen)));
Mots-clefs : Graph (3D), Shading (3D), tube
|
|
|
(Compiled with Asymptote version 1.87svn-r4652)
|
|
import tube;
import graph3;
size(12cm,0);
currentprojection=perspective((-1,1,1));
int p=7, q=3;
real n=p/q;
real a=1, b=1;
real x(real t){return a*cos(t);}
real y(real t){return a*sin(t);}
real z(real t){return b*cos(n*t);}
real R(real t){
real st2=(n*sin(n*t))^2;
return a*(1+st2)^(1.5)/sqrt(1+st2+n^4*cos(n*t)^2);
// return -a*(1+st2)^(1.5)/sqrt(1+st2+n^4*cos(n*t)^2); // Signed radius curvature
}
real mt=q*2*pi;
path3 p=graph(x,y,z,0,mt,operator ..)..cycle;
real m=R(0), M=R(0.5*pi/n);
// Define a pen depending to the radius curvature of graph(x,y,z) at reltime t
pen curvaturePen(real t){
real r=abs(R(t*mt)-m)/(M-m);
return interp(red,blue,r);
}
// Draw the tube, colors depend of the radius curvature R.
draw(tube(p,coloredpath(scale(0.1)*unitcircle, curvaturePen)));
Mots-clefs : Graph (3D), Shading (3D), tube
|
|
|
(Compiled with Asymptote version 1.87svn-r4652)
|
|
import tube;
import graph3;
size(10cm,0);
currentprojection=perspective(4,3,4);
real x(real t) {return (1/sqrt(1+0.5*t^2))*cos(2pi*t);}
real y(real t) {return (1/sqrt(1+0.5*t^2))*sin(2pi*t);}
real z(real t) {return t;}
path3 p=graph(x,y,z,0,2.7,operator ..);
path section=scale(0.2)*polygon(4);
// Define an array of pen wich depends of a real t. t represent the "reltime" of the path3 p.
pen[] pens(real t){
return new pen[] {interp(blue,red,t),
interp(orange,yellow,t),
interp(green,orange,t),
interp(red,purple,t)};
}
// "pen[] pens(real t)" allows to color each nodes or segments with a real parameter (the reltime)
// Note that all arrays of pens are convert to cyclical arrays.
draw(tube(p,coloredpath(section,
pens,
colortype=coloredNodes)));
Mots-clefs : array, Graph (3D), Shading (3D), tube
|
|
|
(Compiled with Asymptote version 1.87svn-r4652)
|
|
import tube;
import graph3;
size(12cm,0);
currentprojection=orthographic(4,3,2);
real x(real t) {return sin(t);}
real y(real t) {return cos(t);}
real z(real t) {return sqrt(t);}
path3 p=graph(x,y,z,0,4pi,50,operator ..);
path section=subpath(unitcircle,0,2);
pen pens(real t){
return interp(red,blue,t);
}
// Define a transformation wich will be applied to each section at reltime t.
transform T(real t){return scale(t^0.75/2);}
// Combination of pens and transform:
draw(tube(p,coloredpath(section,pens), T));
draw(p);
Mots-clefs : Transform (3D), tube
|
|
|
(Compiled with Asymptote version 1.87svn-r4652)
|
|
import tube;
import graph3;
size(12cm,0);
currentprojection=orthographic(1,0,6);
real x(real t) {return sin(t);}
real y(real t) {return 0.5*sin(2*t);}
path g=graph(x,y,0,2pi,50,operator ..);
path3 p=path3(scale(5)*g);
pen[] pens(real t){
real tt=1-2*abs(t-0.5);
return new pen[] {interp(red,blue,tt), interp(blue,red,tt)};
}
draw(tube(p,
coloredpath(polygon(5),pens,colortype=coloredNodes)));
label("colortype=coloredNodes",8*X);
draw(tube(shift(10*Y)*p,
coloredpath(polygon(5),pens,colortype=coloredSegments)));
label("colortype=coloredSegments",8*X+10Y);
Mots-clefs : Shading (3D), tube
|
|
|
(Compiled with Asymptote version 1.87svn-r4652)
|
|
import tube;
import graph;
size(12cm,0);
currentprojection=perspective(4,3,6);
real f(real t) {return cos(2*t);}
path g=polargraph(f,0,2pi,10,operator ..)&cycle;
path3 p=path3(scale(20)*g);
draw(tube(p,rotate(60)*polygon(3)), 0.8*red);
draw(tube(shift(Z)*p,scale(0.25)*unitcircle), orange);
draw(shift(1.25*Z)*p);
Mots-clefs : Graph, path, tube
|
|
|
(Compiled with Asymptote version 1.87svn-r4652)
|
|
import tube;
import graph;
size(12cm,0);
currentprojection=perspective(0,3,6);
real f(real t) {return cos(2*t);}
path g=polargraph(f,0,2pi,10,operator --)&cycle;
path3 p=path3(scale(20)*g);
draw(tube(p,2W--2E), red, bp+black);
draw(tube(p,unitcircle), orange, bp+black);
Mots-clefs : Graph, path, tube
|
|
|
(Compiled with Asymptote version 1.87svn-r4652)
|
|
import tube;
import graph3;
import palette;
size(12cm,0);
currentprojection=perspective(1,1,1);
int e=1;
real x(real t) {return cos(t)+2*cos(2t);}
real y(real t) {return sin(t)-2*sin(2t);}
real z(real t) {return 2*e*sin(3t);}
path3 p=scale3(2)*graph(x,y,z,0,2pi,50,operator ..)&cycle;
pen[] pens=Rainbow(15);
pens.push(black);
for (int i=pens.length-2; i >= 0 ; --i)
pens.push(pens[i]);
path sec=subpath(Circle(0,1.5,2*pens.length),0,pens.length);
coloredpath colorsec=coloredpath(sec, pens,colortype=coloredNodes);
draw(tube(p,colorsec));
Mots-clefs : Graph (3D), palette, Shading (3D), tube