Skip to main content
Participating Frequently
January 15, 2020
Question

Curved lines from Series of (x, y)'s

  • January 15, 2020
  • 4 replies
  • 1129 views

Hi

I have a series of points (Actually many series each of thousands of points) which I want to draw a smooth line through, can this be done programmatically? 

The forum posts Ive found say not but Im really hoping that Im missing something. 

Thanks 

 

 

This topic has been closed for replies.

4 replies

Jacob Bugge
Community Expert
Community Expert
January 15, 2020

Hi Carlos,

 

Thank you for joining, to my relief.

 

CarlosCanto
Community Expert
Community Expert
January 16, 2020

Hi Jacob, of course, always.

Jacob Bugge
Community Expert
Community Expert
January 15, 2020

For my part you are welcome, Nick.

 

The forums move in mysterious ways.

 

CarlosCanto
Community Expert
Community Expert
January 15, 2020

we can definitely plot a series of corner x,y values. Handles can also be ploted if we had the coodinates.

 

I played with this shape manually, so there might be hope. I added a some more points then I simplify converting to curves. Results seem decent.

Participating Frequently
January 15, 2020

Hi Carlos

We have the Handles! Sry if my reply was too brief - I wrote a fuller one but must have broken the guidelines as it was removed as spam.

If you; download the sheet https://1drv.ms/x/s!AuIJtBoQdK8Dq7J0OL0M4zXawt_mlQ and add (x,y)'s

the results in [p1x,p1y],[p2x,p2y] are the locations of handles

Participating Frequently
January 15, 2020

EDITT: deleted

 

Jacob Bugge
Community Expert
Community Expert
January 15, 2020

Nick,

 

We can only hope that one of our scripting friends such as Carlos and Theunis can give the (hopefully hopeful) answer; the earlier special scripting forum has been merged with this one, so this is the right place to ask.

 

Or you can try a completely different approach, namely to use a completely different application to create ugly angular paths, then take it from there, in ways depending on whether you wish to retain all Anchor Points or they are just the beginning, maybe through scripts or whatever, maybe through inherent ways such as Smooth or Simplify, read more about those here and maybe link/search on,

 

https://helpx.adobe.com/illustrator/using/editing-paths.html

 

 

Participating Frequently
January 15, 2020

Hi Jacob, thanks for the reply. 

I have come from a different approach using Excel which plots the data but displays poorly, and also Exporting from Excel into coreldraw which works well on its older versions. 

I was really just hoping that I was wrong and Illustrator could take a set of points and join them up with a smooth line. Hoping but not really expecting I went on with finding out how to draw the line using bezier control points programmatically, made some progress after reading Rob Spencer's -  http://scaledinnovation.com/analytics/splines/aboutSplines.html 

and produced a spreadsheet based on the maths there, that takes a series of (x,y)'s and outputs where the handles to control the curve should be.

I'll put the formulas here in case anybody else wants to run with this in Illustrator but Ive dropped back to my old ways. 

 

Working from the above link I created a sheet with the folowing headings (starting in Column B, ROW 8😎

xyd01d12fafbplxplyp2xp2y

and added two rows with just the (x,y) colums filled - this is needed to calculate the shape of the curve into the first used curve which will start at point 3.

In the third row of data (here using ROW 11)  I put the following formula 

x = a number in Column B
y = a number in Column C
d01 =SQRT(POWER(B10-B9,2)+POWER(C10-C9,2))
d12 =SQRT(POWER(B11-B10,2)+POWER(C11-C10,2))
fa =t*D11/(D11+E11)
fb =t*E11/(D11+E11)
plx =B10-F11*(B11-B9)
ply =C10-F11*(C11-C9)
p2x =B10+G11*(B11-B9)
p2y =C10+G11*(C11-C9)

 The 't' in the formulas is a named range and contains a number between 0-1 which alters how tight the curves are in the final path.

For each row you add x,y to and copy down the formula to, you end up with 

x,y - the point the line runs thru

plx,ply - 1st control handle location

p2x, p2y - 2nd control handle location

 

Ive not done anything with this and may have got it all wrong, so if one of the scripters can do something to test and feedback that would inform others. 

 

Single lined images from Excel (dark background) and CD

https://photos.app.goo.gl/c4MKz2zpq44DyKb88