Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3458996
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:03:10+00:00 2026-05-18T10:03:10+00:00

What is a good way to draw a smooth curve with specified starting and

  • 0

What is a good way to draw a smooth curve with specified starting and ending point and restricted to be inside of a piecewise linear tube like below?


(source: yaroslavvb.com)

coords = {1 -> {0, 2}, 2 -> {1/3, 1}, 3 -> {0, 0}, 
   4 -> {(1/3 + 2)/2, 1}, 5 -> {2, 1}, 6 -> {2 + 1/3, 0}, 
   7 -> {2 + 1/3, 2}};
gp = GraphPlot[graph, VertexCoordinateRules -> coords];
pr = {{-1, 3 + 1/3}, {-1 - 1/6, 3 + 1/6}};
scale = 50;
is = -scale*(Subtract @@@ pr);
lineThickness = 2/3;
graph = {1 -> 2, 3 -> 2, 2 -> 4, 4 -> 5, 5 -> 6, 5 -> 7};
path = {3, 2, 4, 5, 7};
lp = Graphics[{Blue, Opacity[.5], 
    AbsoluteThickness[lineThickness*scale], Line[path /. coords]}];
Show[lp, gp, PlotRange -> pr, ImageSize -> is]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T10:03:10+00:00Added an answer on May 18, 2026 at 10:03 am

    Perhaps something like this:

    coords = {2 -> {1/3, 1}, 1 -> {0, 0}, 3 -> {(1/3 + 2)/2, 1}, 
       4 -> {2, 1}, 5 -> {2 + 1/3, 2}};
    pr = {{-1, 3 + 1/3}, {-1 - 1/6, 3 + 1/6}};
    scale = 50;
    is = -scale*(Subtract @@@ pr);
    lineThickness = 2/3;
    graph = {1 -> 2, 2 -> 3, 3 -> 4, 4 -> 5};
    gp = GraphPlot[graph, VertexCoordinateRules -> coords];
    path = {1, 2, 3, 4, 5};
    
    f = BezierFunction[
       SortBy[coords /. Rule[x_, List[a_, b_]] -> List[a, b], First]];
    pp = ParametricPlot[f[t], {t, 0, 1}];
    
    lp = Graphics[{Blue, Opacity[.5], 
        AbsoluteThickness[lineThickness*scale], Line[path /. coords]}];
    Show[pp, lp, gp, PlotRange -> pr, ImageSize -> is]  
    

    alt text

    You may gain a better control over the path by adding/removing control points for the Bezier. As I remember “A Bspline is contained in the convex hull of its control points”, so you can add control points inside your thick lines (up and down the middlepoints in actual point set, for example) to bound the Bezier more and more.

    Edit

    The following is a first try to bound the curve. Bad programming, just to get the feeling of what can be done:

    coords = {2 -> {1/3, 1}, 1 -> {0, 0}, 3 -> {(1/3 + 2)/2, 1}, 
       4 -> {2, 1}, 5 -> {2 + 1/3, 2}};
    pr = {{-1, 3 + 1/3}, {-1 - 1/6, 3 + 1/6}};
    scale = 50;
    is = -scale*(Subtract @@@ pr);
    lineThickness = 2/3;
    graph = {1 -> 2, 2 -> 3, 3 -> 4, 4 -> 5};
    gp = GraphPlot[graph, VertexCoordinateRules -> coords];
    path = {1, 2, 3, 4, 5};
    
    kk = SortBy[coords /. Rule[x_, List[y_, z_]] -> List[y, z], 
      First]; f = BezierFunction[kk];
    pp = ParametricPlot[f[t], {t, 0, 1}, Axes -> False];
    
    mp = Table[{a = (kk[[i + 1, 1]] - kk[[i, 1]])/2 + kk[[i, 1]],
        Interpolation[{kk[[i]], kk[[i + 1]]}, InterpolationOrder -> 1][
          a] + lineThickness/2}, {i, 1, Length[kk] - 1}];
    mp2 = mp /. {x_, y_} -> {x, y - lineThickness};
    kk1 = SortBy[Union[kk, mp, mp2], First]
    g = BezierFunction[kk1];
    pp2 = ParametricPlot[g[t], {t, 0, 1}, Axes -> False];
    
    lp = Graphics[{Blue, Opacity[.5], 
        AbsoluteThickness[lineThickness*scale], Line[path /. coords]}];
    Show[pp, pp2, lp, gp, PlotRange -> pr, ImageSize -> is]
    

    alt text

    Edit 2

    Or perhaps better yet:

    g1 = Graphics[BSplineCurve[kk1]]; 
    Show[lp, g1, PlotRange -> pr, ImageSize -> is]    
    

    alt text

    This one scales quite well when you enlarge the image (the previous ones don’t)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is a good way of writing something like this in one line. The
is there good way to draw string with chalk effect? Can I draw a
What is a good way to arrange images in the footer as shown in
Wondering what the best / good way of doing this would be in jQuery.
Question What is a good way of assigning a default value to an optional
Anyone knows a good way to use http live streaming tools on non-Mac platforms?
What is a good way to represent finite automaton in Haskell? How would the
Is there a good way to keep keys from conflicting when using the Microsoft
Is there a good way to start at a given index and move BACKWARDS
What is a good way to persist querystring values in asp.net mvc? If I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.