Displace points along a vector

Hi all,

I have two lists of points along a straight line (setting out of two different sets of elements).

I need each pair of corresponding points from each set of points to be at least 15cm apart.

I would ideally like to get the distances (x) corresponding to x<15cm and move the corresponding point away from its relative point by 15-x.

Sorry, I am having a hard time explaining myself, I hope that was somewhat understandable.

Any help you can give would be greatly appreciated, thanks very much :slight_smile:

Anthony

Let me make sure I’m following you first…

You have a list of distances between points that you would like to plot along a line. For any distance less than 15 you want to shift the point so that the distance is then equal to 15.

Is this shift coming out of the next distance or is it shifting all consecutive points with it?

Hi Nick and thanks for your reply.

I have a list of points (“my points”), and these points (all of which occur along a straight line) must not lie nearer than 15cm from the “other list of points” (which are also found along this line).

If any of “my points” lie within 15cm of the “other list of points”, I would like to shift my point by 15cm (so that point would now lie 15cm + the current distance away from its original position).

For example if it were 6cm away from a point in the “other list of points”, then it would be shifted by 15cm so it would now be 21cm from its current position.

This shift is coming out of the next distance indeed.

Thanks Nick

OK so what happens if you hit a negative?

Starting at index 10 in your example:

  • 20 is greater than 15 so no change. 20
  • 9 is less than 15 so we +15. 24
    That shift comes out of the next distance. (6-15 = -9)
  • -9 is less than 15 so we +15. 6
    6 is still less than 15. Do we add 15 again?

I don’t know exactly what your end goal is but it seems like your logic might need some more attention. Either way, the amount of iteration and constant change to values is going to be handled best in Python.

So here I have paired up all “true” and “false” returns with their corresponding point.

I would then take the corresponding “true” values and move them using the geometry translate function.

All values greater than 15, the “false” returns, would be ignored as a result.

Then I would need to create a new list containing the orginal set of points but with the relevant points overwritten.

At the moment I need to figure out how to separate the list by indices containing “true” and indices containing “false”. That way i can isolate the points which need to be moved.

Ok thanks, I will download python and have a look!

Splitting isn’t needed.

From your true false set up an if statement to return either 0 (true this is more than 15 away) or 15 (false this is closer than 15). Then move each point by the resulting distance along the line’s direction.

Hi Jacob,

I have already tried using the geometry translate node but I don’t think it will accept points. Do you know of a different way by any chance?

Thanks

It certainly accepts points in a rather straightforward way. Build a test graph to show how it’s failing for you and I’ll try and steer you right.

I have actually started looking at it a different way which is better for the overall result. Instead of translating the geometry I instead created a list with all the points translated.

I want to replace points in list 1 with points in list 2 every time x<15 in list 3

image

However I can’t seem to figure out how to make the replace.by.condition work.

Thanks Jacob, much appreciated!

Just use an if statement. Put this a code block:

X<15 ? MovedPoints : OriginalPoints;

Excellent, it works perfectly, thanks a lot.

It seems that your if statement is more suited to my problem than the if statement in dynamo itself.