Path Between Points With Right Angles

Hi All,
I have 2 points (A “Door” of a building and a central inner point).
I want to connect the points with a polyline, using only right angles.
I would like to be able to set the number of breaks in the line, or maximum length of each segment.

Any Ideas of how to accomplish this?
Thanks!

Ideas about the algorithm:

  • Input : your two existing points, the number of breaks you want (say N)
  • Divide the straight segment into N segments. You should get, with your two already existing points, N+1 points.
  • Extract the coordinates of the points you got at the previous step. (say (x0,y0) ; (x1,y1); etc.)
  • Create the lines as follow : from (x0,y0) to (x0,y1), from (x0,y1) to (x2,y1), from (x2,y1) to (x2,y3), from (x2,y3) to (x4,y3), etc. (care about the last iteration, must be (xN,yN))

The way you divide your straight segment will truly define the shape of your final line. You can make segments of equal lengths, scaled with a certain ration, etc.

You can do more complicated path, but you must be more specific in what you want as an output. As you stated it, your problem has to many degrees of freedom you can act on.

2 Likes

Are you looking for it to be random/different each time?

Thanks Mellouze, I’ll try that and see how it goes.
Kenny - I am looking to randomize it to some degree. I eventually want to present a few options to choose from, and maybe even optimize it to find the shortest line.

Thanks a lot!!

The shortest line will be the straight one.
With only right angles, there is no uniqueness of such line. Any line that only go from top to down and from right to left will be the shortest (try to do a little drawing of that).

That was the conclusion of my previous post : you need to define what you mean by this sentence you just said :slight_smile:

1 Like

Hi,
I got it working - I can create diagonal lines with a parametric number of segments - thanks for your breakdown!
I understand what you’re saying about the shortest line - straight is of course the shortest.
I tried the drawing, and was shocked to see you were right! :wink:
So I guess optimizing by length is irrelevant.

I’m still thinking about what exactly I’m looking for in randomization, I’ll update this thread when I’ve defined what I’m trying to do.

Thanks again!

1 Like

How is this? Pick two points and the number of subdivisions and off you go!

randomline.dyn (28.2 KB)

2 Likes

Hi,
Thanks for this graph!
I’m having a small issue running it…

Any idea for a solution?

Ah, do you have any packages installed that also use the Point namespace?
This is related to a known issue #8796
Try replacing the code in that block with this:

pt = Autodesk.Point.ByCoordinates;
lc = DSCore.List.Count;

geom = [Imperative]
{
n = lc(points)-1;
out = ;
for (i in 1…n)
{
out[i-1] = pt(
points[i].X,points[i-1].Y);
}
return = out;
};

This way it should work no matter what packages you might have.
(sorry about the formatting; tabs are apparently not valid on here).

1 Like

Still not working for me… I’m getting a missing parentheses warning although I’ve looked at the code and haven’t found the problem.
strange

Try this :

pt = Autodesk.Point.ByCoordinates;
lc = DSCore.List.Count;

geom = [Imperative]
{
n = lc(points)-1;
out = [];
for (i in 1..n)
{
out[i-1] = pt(points[i].X,points[i-1].Y);
}
return = out;
};

There was an extra dot in the for statement of @Avz previous post.

1 Like

Ahhh whoops. I wonder how that snuck in there… Well done for finding that, though!

Bingo!
Thanks to both of you!