## Smooth lines in 3d

nicksoph
Posts: 27
Joined: Fri Aug 26, 2011 9:38 am

### Smooth lines in 3d

I have a set of x,y, z coordinates and want to plot a smooth line through them rather than just straight lines between and cant seem to find how. Does anybody know if this is possible in Mathematica. Any advice on how I might accheive this using something other than Mathematica would also be appreciated.

To give some detail - there are anywhere between 1000 and 100,000 points and each point also has a rgb value associated with it which is used to colour the line between it and the next point. (see http://nicksoph.wixsite.com/spotline for examples in 2d)

Thanks
nicksoph

scruss
Posts: 2222
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

### Re: Smooth lines in 3d

Those are pretty!

What you're looking for are splines, and Wolfram supports a huge number of them. One of the tricky things about splines is that the curve doesn't go through all of the points, and there's quite an art to choosing control points and “tensions” in the curve sections. Certain types of splines (Catmull-Rom being one) go through all control points, but you've still got to mind some parameters for good results.

Where splines can be really useful is in reducing the number of control points. Most vector graphics packages approximate a circle with four spline quadrants between four control points at the extrema. It's not a perfect circle, but visually good enough. With some judicious spline fits, you might be able to get your thousands of points down to a few hundred.

If you're concerned about the straight line segments making your figures look jaggy, see if you can alter the join between segments from mitre or bevel to round. I find it makes for a cleaner plot.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.

nicksoph
Posts: 27
Joined: Fri Aug 26, 2011 9:38 am

### Re: Smooth lines in 3d

Thanks scruss,
I shall look up splines and see how far I get - many thanks

gjxj
Posts: 1
Joined: Sun Mar 05, 2017 1:52 pm

### Re: Smooth lines in 3d

Interpolation may do the job in a simple way. With a fair number of points a cubic interpolation will give a nice smooth curve.

https://reference.wolfram.com/language/ ... ation.html

scruss
Posts: 2222
Joined: Sat Jun 09, 2012 12:25 pm
Location: Toronto, ON
Contact: Website

### Re: Smooth lines in 3d

cubic interpolation == a form of spline.

If you want to play with (possibly 2D) spline fitting:

Code: Select all

``sudo apt install plotutils``
and feed the spline command some coordinates.
‘Remember the Golden Rule of Selling: “Do not resort to violence.”’ — McGlashan.