Points equal allocation

Dear All,

I have an input file with y,z coordinates of points of a ship line. I want to prepare a code which will read these coordinates and equally divides the line into 20 spaces and write the 21 new points which are now defining the line. I cannot think how the equal devision and re-statement of the points could be executed.

Many thanks in advnace!

1 Like

@Spap, welcome to the forum. I am not sure that I understand your question, but here is an attempt:

  • Do you know in advance how many points you have? Otherwise the simplest approach is to use sufficient large arrays, say arrays of 100 points, so that you can just read in the data.
  • Splitting up the ship line in equal parts means that you have to determine the distance along the ship line? Easiest way is to determine the distance between consecutive points on your ship line (line pieces!) and determine points along each line piece that have the right distance to each other.
  • If you end up with a shorter piece at the end of one line piece, subtract that length from the first segment of the next one.
  • Several other details do come to mind :wink:

Not sure what a “ship line” is, especially given you refer to “y,z” points, rather than x,y. ( ship shape or ship route come to mind)
Why do you want to divide “equally” ?
Smoothing the string to reduce the number of defining points could involve removing points from a point sequence that describe a near strait sub-list of y,z points, ie assess each 3 point set and estimate how “off straight” each mid point is, then sort and remove the least “off-straigth” points. This should be a very quick filter applied repeatidly till only 20 points remain.
This approach could best define the string with minimum points.

The main issues are:

  1. how many points in the initial set then
  2. how to read the points.
  3. how to slect points to remove.

To robustly address the first point, could involve reading the points twice, first to count then second to store.
If you don’t want to address the first point, choose a safe large number of possible points.
Once you have completed the second step, you can then try different sets of 20 spaces, using different strategies, then choose the best.
Address each stage seperately and the problem could be easier to solve.

Dear John, Dear Arjen,

Thank you for your prompt replies. As per ship line a mean a ship section which is been difined by y,z corrdinates that have the same x value (longitudinal position). You may see below a graph of a ship section. This section has been equally divided in 24 spaces (theorytically). I know in advance the number of the points of the section and I also know that every section has to be divided into 20 spaces. I think of creating a spline curve or polynomial curve and then choosing points from this curve, but I am not sure how to define the “equality”.

For this example, the points you present are not “equally spaced” near the corner point that is significant for the shape definition. You really have only 3 significant points.

What is more important, equally spaced or accurately describing the shape ?

A solution might be to have “n” equally spaced points along the bottom and then “20+1-n” equally spaced points along the side wall.

What you appear to have done is define 25 equally spaced points plus one extra significant point to define the shape.

You could use just 3 points, or sufficient points for a spline curve if any surface is curved.

Hi John,

Thank you for your replies, they did really help me. I’ve just figured out that there is no reason for a strict equally division of the curve. So thank you.