Share

Asymptote

Subscribe

shading a surface by weights

  1. 2009-11-11 12:15:36 UTC

    if one can shading a surface according to the specified weights which just like some heat sources?

    for the plane, I finded a way, it is similar to the filesurface.asy. Can we draw it without througth the 3D?

    the data.txt is :

    1      3     4     5
    0     1.4    2     3
    1.0   1.0    1.0   2.0
    0.2   0.3    0.5   0.7
    0.5   0.7    0.2   0.4
    2     1.5    0.9   1.0
    

    ====================================

    settings.render=0;
    
    import graph3;
    import palette;
    
    size(200);
    
    file in=input("data.txt").line();
    real[] x=in;
    real[] y=in;
    
    real[][] z=in.dimension(0,0);
    
    surface s=surface(z,(min(x),min(y)),(max(x),max(y)),Spline);
    
    s.colors(palette(s.map(zpart), Rainbow()));
    
    draw(s,nolight);
    
    //draw(planeproject(unitsquare3)*s,nolight);
    
    currentprojection=orthographic(0,0,1);
    
    limits((0,0,0),(1.1*max(x),1.1*max(y),1.1*max(z)));
    
    xaxis3("$x$",OutTicks(),Arrow3(),above=true);
    yaxis3("$y$",OutTicks(),Arrow3(),above=true);
    

    for the general surface, I don't know how to do. it seems difficult to constructed the temperature distrubution function real(triple v) according to the specified heat sources.

    import palette;
    import graph3;
    
    size(200);
    
    currentprojection=orthographic(1,1,1);
    
    triple[] P={
      (2,  0,  0),
      (-2,  0,  0),
      (0,  2,  0),
      (4,  0,  4),
      (0,  4,  4),
      (-4,  0,  4)
    };
    
    path3 p1=P[0]..P[2]..P[1];
    path3 p2=P[3]..P[4]..P[5];
    
    surface sur=extrude(p1,p2);
    
    real[][] weights={
      {5,15},
      {20,12},
      {10,8},
    };
    
    real distribution(triple v){return sin(v.x*v.z);}//??????
    
    sur.colors(palette(sur.map(distribution),Rainbow()));
    
    draw(sur);
    
    draw(planeproject(unitsquare3)*sur);
    
    axes3("$x$","$y$","$z$",Arrow3());
    
  2. 2009-11-12 01:19:14 UTC

    Sorry, I make some mistake in my code, here is the new

    settings.render=0;
    
    import graph3;
    import palette;
    
    size(200);
    
    file in=input("data.txt").line();
    real[] x=in;
    real[] y=in;
    
    real[][] z=in.dimension(0,0);
    
    surface s=surface(z,x,y);
    
    s.colors(palette(s.map(zpart), Rainbow()));
    
    draw(s,nolight);
    
    //draw(planeproject(unitsquare3)*s,nolight);
    
    currentprojection=orthographic(0,0,1);
    
    limits((0,0,0),(1.1*max(x),1.1*max(y),1.1*max(z)));
    
    xaxis3("$x$",OutTicks(),Arrow3(),above=true);
    yaxis3("$y$",OutTicks(),Arrow3(),above=true);
    
  3. 2009-11-12 09:47:30 UTC

    for the general cace, I constructed another surface and using the map, but it seems not the good way

    import palette;
    import graph3;
    size(200);
    
    currentprojection=perspective(2,-12,6);
    
    triple[] P={
      (2,  0,    0),
      (0,  2,    0),
      (-2, 0,   0),
      (4,  0,    4),
      (0,  4,    4),
      (-4, 0,   4)
    };
    
    triple [] Q={
      (2,  0,   10),
      (0,  2,   20),
      (-2, 0,  5),
      (4,  0,   8 ),
      (0,  4,   12),
      (-4, 0,  15)
    };
    
    surface p=extrude(P[0]..P[1]..P[2],P[3]..P[4]..P[5]);
    
    surface q=extrude(Q[0]..Q[1]..Q[2],Q[3]..Q[4]..Q[5]);
    
    p.colors(palette(q.map(zpart),Rainbow()));
    
    draw(p);
    
    axes3("$x$","$y$","$z$",Arrow3());
    
< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.