PIPRIME.FR BLOG

Live fully to honor life

Tag Wire frame -- Asymptote Gallery

đź”—solids-fig003

Figure solids 003 Generated with Asymptote

Show solids/fig0030.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Examples 3D | Solids.asy
Tags : #Solid | #Revolution | #Projection (3D) | #Draw (3D) | #Surface | #Sphere | #Wire frame | #Line type

// Author: John Bowman.
size(6cm, 0);
import solids;
currentprojection=orthographic(0, 10, 5);

nslice=4*nslice;

revolution r=sphere(O, 1);
draw(surface(r), lightgrey+opacity(0.75));

skeleton s;
r.transverse(s, reltime(r.g, 0.6), currentprojection);
r.transverse(s, reltime(r.g, 0.5), currentprojection);
draw(s.transverse.back, linetype("8 8", 8));
draw(s.transverse.front);

r.longitudinal(s, currentprojection);
draw(s.longitudinal.front);
draw(s.longitudinal.back, linetype("8 8", 8));

đź”—solids-fig010

Figure solids 010 Generated with Asymptote

Show solids/fig0100.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Examples 3D | Solids.asy
Tags : #Solid | #Revolution | #Wire frame | #Surface

unitsize(1cm);
import solids;

currentprojection=orthographic(0, 100, 25);

real r=4, h=7;
triple O=(0, 0, 0);
triple Oprime=(0, 0, 3);
triple pS=(0, 0, h);
triple pA=(r*sqrt(2)/2, r*sqrt(2)/2, 0);
revolution rC=cone(O, r, h, axis=Z, n=1);

draw(surface(rC), blue+opacity(0.5));

skeleton s;
real tOprime=abs(Oprime)/h;
rC.transverse(s, reltime(rC.g, tOprime), currentprojection);
triple pAprime=relpoint(pA--pS, tOprime);
draw(s.transverse.back, dashed);
draw(s.transverse.front);

label("$S$", pS, N);
dot(Label("$O$", align=SE), O);
dot(Label("$O'$", align=SE), Oprime);
dot(Label("$A$", align=Z), pA);
dot(Label("$A'$", align=Z), pAprime);

draw(pS--O^^O--pA^^Oprime--pAprime, dashed);

đź”—solids-fig011

Figure solids 011 Generated with Asymptote

Show solids/fig0110.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Examples 3D | Solids.asy
Tags : #Solid | #Revolution | #Wire frame | #Sphere

import solids;
unitsize(4cm);

currentprojection=orthographic(2,2,1);

draw(cylinder(c=(0,0,-1.5),r=1,h=3), m=3);
draw(sphere(r=1), m=2, frontpen=defaultbackpen);

đź”—solids-fig012

Figure solids 012 Generated with Asymptote

Show solids/fig0120.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Examples 3D | Solids.asy
Tags : #Solid | #Intersection | #Revolution | #Wire frame | #Markers

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,
                    real radius=0,
                    pen p=currentpen,
                    pen fillpen=nullpen,
                    projection P=currentprojection)
{
  p=linejoin(0)+linecap(0)+p;
  if (radius==0) radius=arrowfactor*sqrt(2);
  transform3 T=shift(-M);
  triple OA=radius/sqrt(2)*unit(T*A),
    OB=radius/sqrt(2)*unit(T*B),
    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);
  add(pic, pic_, M);
}

// *...............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);

đź”—three-fig005

Figure three 005 Generated with Asymptote

Show three/fig0050.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Examples 3D | Three.asy
Tags : #Geometry (3D) | #Wire frame | #Line type | #Intersection | #Interp

import three; import math;
size(8cm,0);
currentprojection=obliqueX;

real h=2;
triple A =(0,0,h), B=(h,0,0), C=(0,h,0), D=(0,0,0);
triple Ip=midpoint(A--C), J=midpoint(A--B);
triple K=shift((0,0,-0.25*h))*A;

triple M=interp(K,J,intersect(K,J,normal(new triple[]{B,C,D}),D));
triple Np=interp(K,Ip,intersect(K,Ip,normal(new triple[]{B,C,D}),D));

dot("$A$", A, align=Z);  dot("$B$", B, align=S);
dot("$C$", C, align=S);  dot("$D$", D, align=W);
dot("$I$", Ip, align=N); dot("$J$", J, align=W);
dot("$K$", K, align=NE); dot("$M$", M, align=SE);
dot("$N$", Np, align=S);

draw(A--B--C--cycle^^B--M^^C--Np^^J--M^^Ip--Np);
draw(A--D--C^^D--B^^J--K^^K--Ip, dashed);

đź”—three-fig007

Figure three 007 Generated with Asymptote

From the Asymptote forum.

Show three/fig0070.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Examples 3D | Three.asy
Tags : #Bsp | #Wire frame | #Plan

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;
addshapes(faces, group1, drawpen=linewidth(0.25bp), fillpen=opacity(0.35)+red);
addshapes(faces, group2, drawpen=linewidth(0.25bp), fillpen=opacity(0.5)+lightblue);
addshapes(faces, group3, drawpen=linewidth(0.25bp), fillpen=opacity(0.5)+lightyellow);
add(faces);

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

đź”—three-fig008

Figure three 008 Generated with Asymptote

Show three/fig0080.asy on Github.
Generated with Asymptote 3.00-0.
Categories : Examples 3D | Three.asy
Tags : #Bsp | #Wire frame | #Line type | #Plan

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;
addshapes(hidden, group, drawpen=linewidth(bp));
addshapes(visible, group, drawpen=dotted, fillpen=nullpen);
add(hidden);
add(visible);

shipout(format="pdf");

0%