Menu

NURBS curves and pens

Help
2016-10-30
2016-11-27
  • Bernhard Karl Bachner

    Hello,
    is there a possibility to apply different line types or line widths to a NURBS curve? The example NURBScurve.asy from the gallery shows how to define different colors for NURBS curves. The following code draws a circle by means of a NURBS and the polygon of the base points.

    import three;
    import graph3;
    
    size(100mm);
    
    currentprojection = perspective(50,80,50);
    
    real[] U = {0., 0., 0., 0.25, 0.25, 0.5, 0.5, 0.75, 0.75, 1., 1., 1.};
    triple[] P = {
      (1., 0., 0.),
      (1., 1., 0.),
      (0., 1., 0.),
      (-1., 1., 0.),
      (-1., 0., 0.),
      (-1., -1., 0.),
      (0., -1., 0.),
      (1., -1., 0.),
      (1., 0., 0.)
    };
    real[] w = {1., 1./sqrt(2), 1., 1./sqrt(2), 1., 1./sqrt(2), 1., 1./sqrt(2), 1.};
    draw(P, U, w, red+0.5mm+dashed);
    
    path3 p = graph(P, operator --);
    draw(p, black+dotted);
    dot(p, black);
    

    Unfortunately the settings for the pen "0.5mm+dashed" are ignored for the NURBS curve. Is there a way to get the specified linewidth and the dash pattern rendered correctly?

     
  • John Bowman

    John Bowman - 2016-11-01

    At this time, NURBS are barely supported in Asymptote. A lot of missing routines (bounds, intersection, etc.) would have to be written to support them in the way that Bezier curves, triangles, and surfaces are supported. To embark on such a project, I would need to see some examples to persuade me that it would be worth the effort (as well as the extra complexity in the language). The next new feature, coming soon, is WebGL (HTML5) support of Bezier objects.

     
    • Michail Vidiassov

      Hello John,

      you wrote:

      The next new feature, coming soon, is WebGL (HTML5) support of Bezier objects.
      are you going to do tessellation in C++, asy language or JavaScript?
      If you start exporting Bezier objects for WebGL as sets of triangles and segments it'll make possible export to many 3D formats like X3D.

       
  • Bernhard Karl Bachner

    Hello John,

    thank you for your quick reply. Your answer points out clearly that full support for NURBS (a similar level of what is possible for cubic bezier objects) needs a lot of work.

    Bernhard

     

Log in to post a comment.