Point List Rotation

Hi,
I’m trying to create a script to autonumbering the beams. For the moment, I managed to do it from left to right (from the smallest value of the x to the largest).

However, I would like to change the angle of the X axis. I would like that the reading order of the points was taken in oder angle. (sorry for my english).

Thank you.

Hi,

Try to query both coordinates (X and Y), and compute a combination between both to have the desired axis.

For instance, computing pts.X+pts.Y (where pts is the list of points you have) will give you the “coordinate” along the first bisectrix.

Hi,

Thank you for helping!
I’m sorry but I didn’t understand well. Do I need to use a specific node?

In your screenshot, you are sorting your points by using the Point.X node. You should change that node so you can sort them by a linear combination of Point.X and Point.Y.

By changing that node by the right linear combination, you should get the sorting you want.

Capture1

Example :

You want to sort a list of points that are aligned on the first bisectrix.

  1. Get the first bisectrix equation ( obvisouly, y=x )
  2. Invert the sign of the coefficient of either ‘y’ or ‘x’ ( y=x –> 1 y = -1 x)
  3. Invert the coefficients ( 1 y = - 1 x –> - 1 y = 1 x )
  4. Get the two variables to the same side of the equation ( 1 x + 1 y = 0 )

What you get at the left of the final equation is the linear combination you need (i.e. you want to replace pt.X by 1 pt.X + 1 pt.Y).

If you wanted to sort a list of points aligned on a line whose equation is : a x = b y , you’ll need to compute --> b pt.X + a pt.Y

Example 2 :

The equation of the X axis is : y = 0, i.e. 1 y = 0 x. Thus, the combination you should use : 1 pt.X + 0 pt.Y. This combination is strictly the same as : pt.X (linear combination that you are currently using).

Thank you very much.
I think I understood more or less. If I would a desired angle of 41.9° I’ll need to compute.

1 pt.X - 0.897 pt.Y

I think it should be : 1 pt.X + 0.897 pt.Y.

Yes. I don’t know but it works for me like that.

Thanks a lot.

1 Like

Glad I helped !