Menu

Rescaling all triples

Help
2016-05-19
2016-05-20
  • Duncan Murdoch

    Duncan Murdoch - 2016-05-19

    I think this is possible, but I don't see how to do it.

    I'd like to specify different scaling for each of the x, y and z coordinates, and have this apply to everything that is plotted afterwards. For example, I might want to apply scaling of (1, 2, 3) to (x, y, z); then a line drawn from (0,0,0) to (1,1/2,1/3) would be rescaled so that it appeared to go the same distance in all three coordinates.

    I see in the graph3.asy code things like

    pic.scale.x.T(x);
    

    which suggests this is being used, but I don't see where the scale is set.

     
  • Charles Staats

    Charles Staats - 2016-05-19

    If you're willing to settle for scaling everything drawn so far rather than everything potted afterwards, you could use

    currentpicture = scale(1,2,3) * currentpicture;
    
     
  • Duncan Murdoch

    Duncan Murdoch - 2016-05-20

    Thanks for the suggestion, but that rescales ticks in my graph axes too, so it doesn't look good.

    Some background: I'm generating Asymptote code automatically, so I can rescale things before sending them to Asymptote. The problem then is with axes, which show rescaled numbers rather than
    the original numbers.

    So maybe my question should have been: How do I generate an axis with tick locations given in a real[] array, and the labels for those ticks given in a string[] array?

     
  • Duncan Murdoch

    Duncan Murdoch - 2016-05-20

    I have a partial answer to my revised question. I can create a function to rescale tick values before formatting them; this is sufficient for my needs.

    Specifically: assuming the points are rescaled before Asymptote sees them, I can use code like

    ticklabel RGLScale(real s)
    {
      return new string(real x) {return format(s*x);};
    }
    xaxis3(axis=YZEquals(y=-2.282996, z=-2.406974),
              xmin=-2.987038, xmax=1.257171,
              ticks = Ticks3(1, Ticks = new real[] {-2.7418094170615,
              -1.82787294470766,-0.913936472353832,0,0.913936472353832},
                          ticklabel = RGLScale(0.00547084)));
    

    and the ticks end up displayed on the original scale: -0.015, -0.01, -0.005, etc.

     

Log in to post a comment.